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.

pip freeze figures out the current commit SHA for a git repo but not (reliably) the current branch

See original GitHub issue

The problem originates from this line.

names_by_commit = dict((commit, ref) for ref, commit in refs.items())

When local branches track up to date remote branches, the mapping from SHA to branch is not unique and remote branches with syntax “origin/my_branch” may be picked (see comment in the code), even though they are NOT checked out.
Finally, pkg_resources does not allow a slash in the version pattern and raises a ValueError if a branch name containing a slash is picked.

My use case: I have a local git repo which originates from a different local path on my file system. I installed it via:

pip install -e c:/workspace/my_proj

Now I do

pip freeze > requirements.txt

The file looks something like this:

-e git+<path_to_origin>/my_proj.git@<SHA>#egg=my_proj-origin/<branch>

If I then create a new virtual environment and try to install my requirements file I get an error in pip_vendor\pkg_resources.py", line 2573, in scan_list.

ValueError: ('Expected version spec in', 'my_proj-origin/<branch>', 'at', '/<branch>')

I noticed that the problem goes away when the line in the requirements file reads:

-e git+<path_to_origin>/my_proj.git@<SHA>#egg=my_proj-<branch>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sbidoulcommented, Jan 29, 2020

The branch is not emitted by pip freeze anymore since https://github.com/pypa/pip/pull/3312, only the commit id. So we’ll let the bot close this unless there is a reaction otherwise.

0reactions
no-response[bot]commented, Feb 13, 2020

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip freeze gives me this error related with git - Stack Overflow
Hi. I have updated pip with sudo pip install --upgrade distribute within its virtual environment, but it is still giving me the same...
Read more >
Building a Secure Software Supply Chain with GNU Guix - arXiv
Git itself allows individual commits and tags to be authenticated but offers no way to authenticate a complete checkout—making sure each commit was...
Read more >
pip install pip==1.0.2 - PyPI
pip. pip is a tool for installing and managing Python packages, such as those found in the Python Package Index. pip is a...
Read more >
Changelog — Python 3.11.1 documentation
gh-95174: Python now skips missing socket functions and methods on WASI. WASI can only create sockets from existing fd / accept and has...
Read more >
Changelog - pip documentation v22.3.1
A package in a wheel is (by definition) not installed, and is not ... Log the resolved commit SHA when installing a package...
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