Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 52679:30510238284e
packaging: get version with setuptools-scm
Now that Mercurial is compatible with PEP 517, i.e. that setup.py is called
by a PEP 517 frontend (pip, build, pipx, UV, ...) in an isolated environment,
we can use setuptools-scm to obtain the version when building from the repo.
After these changes, it is no longer supported to get the version from the
repo when Mercurial is not installed.
Of course, it is still possible to install Mercurial from source without
Mercurial by getting an archive of the repo or the sdist on PyPI.
A case becomes slightly more complicated: building mercurial from source in
an environment where you cannot download anything from the web. One would
need to get setuptools and setuptools-scm wheels from PyPI, transfer them
to the computer, create a venv, install setuptools and setuptools-scm with
pip in the venv and install Mercurial with
`pip install . --no-build-isolation`.
Of course, it is still very simple to install Mercurial in an environment
where you cannot download anything from the web: just get a wheel and install.
No need for setuptools and setuptools-scm in this case.
author | paugier <pierre.augier@univ-grenoble-alpes.fr> |
---|---|
date | Fri, 25 Oct 2024 11:15:29 +0200 |
parents | e627cc25b6f3 |
children | 4eede65d68cf |
comparison
equal
deleted
inserted
replaced
52678:8370eb2c72ca | 52679:30510238284e |
---|---|
1195 def version(): | 1195 def version(): |
1196 """Return version information if available.""" | 1196 """Return version information if available.""" |
1197 try: | 1197 try: |
1198 from . import __version__ # pytype: disable=import-error | 1198 from . import __version__ # pytype: disable=import-error |
1199 | 1199 |
1200 return __version__.version | 1200 # setuptools-scm uses py3 str |
1201 return __version__.version.encode() | |
1201 except ImportError: | 1202 except ImportError: |
1202 return b'unknown' | 1203 return b'unknown' |
1203 | 1204 |
1204 | 1205 |
1205 def versiontuple(v=None, n=4): | 1206 def versiontuple(v=None, n=4): |