Wrong version detection with setuptools_scm, `pip install .` and hg-git
See original GitHub issueDescription
I try to install a package (https://github.com/exabl/snek5000) with pip install -e .
cloned with Mercurial and hg-git.
This package uses setuptools_scm to detect its version. setuptools_scm now supports using Mercurial as a Git client and provides the right version when using the commands python setup.py develop
and pip install -e . --no-build-isolation
.
However, if I just use pip install -e .
, the package is correctly installed but the detected version is completely wrong.
Expected behavior
No response
pip version
pip 21.3.1
Python version
CPython 3.9
OS
Linux
How to Reproduce
With Mercurial setup to work with hg-git
hg clone git@github.com:exabl/snek5000.git
cd snek5000
pip install -e .
Output
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (12 by maintainers)
Top Results From Across the Web
setuptools_scm not working with `pip install .` in case of .git in ...
LookupError: setuptools-scm was unable to detect version for '/tmp'. ERROR: Command errored out with exit status 1: python setup.py egg_info ...
Read more >setuptools_scm - setuptools-scm · PyPI
setuptools_scm handles managing your python package versions in scm metadata instead of declaring them as the version argument or in a scm managed...
Read more >mercurial / hg-git · GitLab - Heptapod
This plugin is implemented entirely in Python — there are no Git binary dependencies, and you do not need to have Git installed...
Read more >setuptools-scm Changelog - pyup.io
fix 707: support git version detection even when git protects against ... add ``--strip-dev`` flag to ``python -m setuptools_scm`` to print the next...
Read more >Versioning your package with setuptools_scm | by Moritz Körber
Version metadata are like charging cables: Versioning your package ... live on the Python Package Index (PyPI), you must include a version.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I try to summarize. I think this issue is now quite well understood.
It is related to the custom isolation used by pip and to the sensibility of (at least some) Mercurial installations to environment variables like
PYTHONPATH
andPYTHONNOUSERBASE
.The solutions could be:
Improve Mercurial in terms of ignoring Python specific environment variables. I don’t know at which level it should be done. I guess it depends somehow on the installation method. Even if the next version of Mercurial is improved, the issue will continue to be there for most users since people tend to use quite old versions of hg.
Implement the Mercurial isolation at the setuptools_scm level, i.e. remove
PYTHONNOUSERBASE
and cleanPYTHONPATH
for the environment used to callhg
. It’s technically very simple (I can even submit a PR) and could also work with other installation tools for installation using setuptools_scm.Use internally in pip a proper virtual environment created with
venv --without-pip
(no need to use/changePYTHONNOUSERBASE
andPYTHONPATH
). It would fix other similar problems, in particular for other Python applications used during build. It would not fix the problem for other install tools, except if there is also a pep on “expectations for how tools set up the build environment”.Yeah looks right to me!