Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip freeze includes the current directory, if there is an egg-info. #2926

Closed
tomprince opened this issue Jun 24, 2015 · 18 comments · Fixed by #7955, #7987 or #8012
Closed

pip freeze includes the current directory, if there is an egg-info. #2926

tomprince opened this issue Jun 24, 2015 · 18 comments · Fixed by #7955, #7987 or #8012
Labels
auto-locked Outdated issues that have been locked by automation C: freeze 'pip freeze' related good first issue A good item for first time contributors to work on type: enhancement Improvements to functionality

Comments

@tomprince
Copy link

At least when the current directory is a git repository. In addition, it treats as something wanting -e and also gives it the wrong #egg (it appears to give it <package-name>-<git-branch> as the #egg).

@tomprince
Copy link
Author

The egg-info part is #2926

@dstufft
Copy link
Member

dstufft commented Mar 24, 2017

I believe that this can be solved by just skipping . when iterating over sys.path looking for installed projects.

@pradyunsg pradyunsg added good first issue A good item for first time contributors to work on type: enhancement Improvements to functionality labels Oct 17, 2017
@jadkik
Copy link

jadkik commented Nov 1, 2017

Can this be fixed by adding a custom skip list in addition to the standard ('pip', 'setuptools', 'distribute', 'wheel') and expose that in the command arguments?

There may be several internal development packages that are installed in a single virtual environment.

@kaikulimu
Copy link

Hi, I am from PyPA Sprint Weekend at Bloomberg (2018), and I will work on this!

@kaikulimu
Copy link

Add PR: #5951

@gokcennurlu
Copy link

How can we reproduce this, by the way?

@kynan
Copy link
Contributor

kynan commented Oct 28, 2018

@pradyunsg Please move to in progress

@DavidBord
Copy link
Contributor

@pradyunsg I cannot seem to reproduce. The steps I did:
checkout a git project of a python package
python setup.py bdist_wheel --universal
pip freeze - didn't see the egg.info
cd dist
pip freeze - didn't see the egg.info
cd ../
mv dist/*.egg-info .
pip freeze - didn't see the egg.info

Please advice

@gutsytechster
Copy link
Contributor

@pradyunsg, is this issue resolved. I see a PR closed regarding this #5951. Does the change in this PR is what intended to be done?

@uranusjr
Copy link
Member

It’s not fixed; the PR was closed because it was abandoned in a non-mergeable state. Feel free to re-apply the changes and submit a new PR against master.

@gutsytechster
Copy link
Contributor

Great! I'd like to work on it. :)

@uranusjr
Copy link
Member

Cross-referencing #7731; this might be the reason why some had trouble reproducing the issue.

@gutsytechster
Copy link
Contributor

@uranusjr Thanks for the pointer. I was able to reproduce the same behaviour with pip freeze.

@gutsytechster
Copy link
Contributor

Is it about providing the same behaviour for pip freeze, when used with and without python -m? As without python -m, pip does not include the current directory. But with it, pip does.

Also, I tried to test my change first by installing an updated version of pip by running the command python setup.py install, within the virtual environment.

So, when I do pip --version within my virtual-env, I get pip 20.1.dev0 from /home/gutsytechster/miniconda3/envs/pip-env/lib/python3.6/site-packages/pip-20.1.dev0-py3.6.egg/pip (python 3.6) i.e. it does fetch pip from the installed package. However, when trying to get the version using python -m pip --version, I get pip 20.0.2 from /home/gutsytechster/miniconda3/envs/pip-env/lib/python3.6/site-packages/pip (python 3.6). Why is there a difference of version?

@uranusjr
Copy link
Member

Is it about providing the same behaviour for pip freeze, when used with and without python -m? As without python -m, pip does not include the current directory. But with it, pip does.

That’s (what I consider) correct, but we’d need to first found out what causes this different behaviour before we decide on the solution.

For the experiement, the difference is due to Setuptools (or distutils?) uses a different logic to load the module in the the entry point script (see cat /miniconda3/envs/pip-env/bin/pip) . It’s now condiered a bad idea so pip does not do that (the one it uses is more similar to python -m). The “solution” is to just not run setup.py install at all, it’s a bad idea.

@gutsytechster
Copy link
Contributor

gutsytechster commented Feb 28, 2020

I run python setup.py install to just install my changes to the pip within virtual environment. so that I can test manually as well, the changes I've made. Is there some other way to achieve this?

@uranusjr
Copy link
Member

You can replace that with pip install . (the last dot means pwd, not a period).

@gutsytechster
Copy link
Contributor

Thank you! That really helped. python -m pip now also takes the pip version which I install via pip install .

gutsytechster added a commit to gutsytechster/pip that referenced this issue Mar 1, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
gutsytechster added a commit to gutsytechster/pip that referenced this issue Mar 1, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
gutsytechster added a commit to gutsytechster/pip that referenced this issue Mar 1, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
gutsytechster added a commit to gutsytechster/pip that referenced this issue Mar 1, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
gutsytechster added a commit to gutsytechster/pip that referenced this issue Mar 28, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
gutsytechster added a commit to gutsytechster/pip that referenced this issue Apr 2, 2020
This skips any *.egg_info present in the current directory when
performing pip freeze.

This fixes pypa#2926
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 5, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: freeze 'pip freeze' related good first issue A good item for first time contributors to work on type: enhancement Improvements to functionality
Projects
None yet