Pip freeze not properly showing git dependency in venv

Viewed 298

I've pip installed some python packages from a git repository into a venv using the command:

python -m pip install git+ssh://git@git.privateurl.com/repos/my-private-package.git

Now, when i run pip freeze, the package appears like a 3rd party package like my-private-package=0.2.1 rather than of the form:

my-private-package @ git+ssh://git@git.privateurl.com/repos/my-private-package.git

How can I force it to appear as the latter so that when i generate the requirements.txt it is easily shared to other colleagues who just have to run python -m pip install -r requirements.txt ?

I've tried different python versions (3.6, 3.7, 3.8). I'm using the latest pip version (21.1.2) and I've tried Ubuntu and Mac and still reproduce the issue. The oddest thing is a colleague can run the same commands and get the right results.

2 Answers

I don't know how/if pip freeze will do this, but you can use pip-compile (from the pip-tools package) to turn a requirements.in list with a git url into a requirement list that still has a git-url. The accompanying pip-sync will synchronize your virtualenv packages to those specified in the requirements list.

There might be a problem with directory containing egg-info in the package you're trying to install. Try to delete it and then reinstall the package using pip install -e. It will create new directory with proper egg-info.

Related