pip: Wrong version detection with setuptools_scm, `pip install .` and hg-git
Description
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.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 19 (12 by maintainers)
Commits related to this issue
- Clean environnent variables to avoid an incompatibility between pip isolated build and hg (https://github.com/pypa/pip/issues/10635) — committed to paugier/setuptools_scm by paugier 2 years ago
- Clean environnent variables to avoid an incompatibility between pip isolated build and hg (https://github.com/pypa/pip/issues/10635) — committed to paugier/setuptools_scm by paugier 2 years ago
- Clean environnent variables to avoid an incompatibility between pip isolated build and hg (https://github.com/pypa/pip/issues/10635) — committed to paugier/setuptools_scm by paugier 2 years ago
- pypi-setuptools_scm: Autospec creation for update from version 7.0.2 to version 7.0.3 Charly C (2): add instructions for Git archives in README fix incomplete template for `.git_archival.... — committed to clearlinux-pkgs/pypi-setuptools_scm by fenrus75 2 years ago
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”.