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.