question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong version detection with setuptools_scm, `pip install .` and hg-git

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
paugiercommented, Nov 12, 2021

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 and PYTHONNOUSERBASE.

The solutions could be:

  1. 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.

  2. Implement the Mercurial isolation at the setuptools_scm level, i.e. remove PYTHONNOUSERBASE and clean PYTHONPATH for the environment used to call hg. It’s technically very simple (I can even submit a PR) and could also work with other installation tools for installation using setuptools_scm.

  3. Use internally in pip a proper virtual environment created with venv --without-pip (no need to use/change PYTHONNOUSERBASE and PYTHONPATH). 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”.

0reactions
uranusjrcommented, Nov 12, 2021

Yeah looks right to me!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found