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 list in JSON format does not contain location for editable installs #7664

Closed
ThimoNeubauer opened this issue Jan 28, 2020 · 4 comments · Fixed by #10249
Closed

pip list in JSON format does not contain location for editable installs #7664

ThimoNeubauer opened this issue Jan 28, 2020 · 4 comments · Fixed by #10249
Labels
C: editable Editable installations C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality

Comments

@ThimoNeubauer
Copy link

Environment

  • pip version: 20.0.2
  • Python version: 3.8.1
  • OS: Windows 10

Description

If a package is installed with pip install -e then the output of pip list contains a location column, e.g.:

E:\temp>foo\Scripts\python.exe -m pip list
Package    Version Location
---------- ------- ------------------
pip        20.0.2
setuptools 45.1.0
six        1.14.0  e:\temp\six-1.14.0

I'd like to use the location information to know which packages are in "editable" mode. Parsing the column format doesn't seem a smart idea, that's what the JSON output is for. However the location parameter is missing in JSON mode:

E:\temp>foo\Scripts\python.exe -m pip list --format json
[{"name": "pip", "version": "20.0.2"}, {"name": "setuptools", "version": "45.1.0"}, {"name": "six", "version": "1.14.0"}]

Expected behavior

I'd expect to see:

E:\temp>foo\Scripts\python.exe -m pip list --format json
[{"name": "pip", "version": "20.0.2"}, {"name": "setuptools", "version": "45.1.0"}, {"name": "six", "version": "1.14.0", "location": "e:\\temp\\six-1.14.0"}]

to match the pip list --format columns output

How to Reproduce

  1. create venv
  2. run python -m pip install --upgrade pip setuptools to be sure to use the latest and greatest versions
  3. python -m pip install -e a source package. For the output above I downloaded the latest six source
  4. run python -m pip list and compare with python -m pip list --format json to see that the location data is missing

Output

E:\temp>mkdir foo

E:\temp>py -3 --version
Python 3.8.1

E:\temp>py -3 -m venv foo

E:\temp>foo\Scripts\python -m pip install --upgrade pip setuptools
Collecting pip
  Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/a7/c5/6c1acea1b4ea88b86b03280f3fde1efa04fefecd4e7d2af13e602661cde4/setuptools-45.1.0-py3-none-any.whl
Installing collected packages: pip, setuptools
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
  Found existing installation: setuptools 41.2.0
    Uninstalling setuptools-41.2.0:
      Successfully uninstalled setuptools-41.2.0
Successfully installed pip-20.0.2 setuptools-45.1.0

E:\temp>curl https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz --output six.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 33857  100 33857    0     0   321k      0 --:--:-- --:--:-- --:--:--  324k

E:\temp>"c:\Program Files\7-Zip\7z.exe" x six.tgz

7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
...

E:\temp>"c:\Program Files\7-Zip\7z.exe" x dist\six-1.14.0.tar

7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
...

E:\temp>foo\Scripts\python -m pip install -e six-1.14.0
Obtaining file:///E:/temp/six-1.14.0
Installing collected packages: six
  Running setup.py develop for six
Successfully installed six

E:\temp>foo\Scripts\python -m pip list
Package    Version Location
---------- ------- ------------------
pip        20.0.2
setuptools 45.1.0
six        1.14.0  e:\temp\six-1.14.0

E:\temp>foo\Scripts\python -m pip list --format json
[{"name": "pip", "version": "20.0.2"}, {"name": "setuptools", "version": "45.1.0"}, {"name": "six", "version": "1.14.0"}]
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jan 28, 2020
@sbidoul
Copy link
Member

sbidoul commented Jan 28, 2020

It would seem that location will appear in the json output in verbose mode only:

if options.verbose >= 1:
info['location'] = dist.location
info['installer'] = get_installer(dist)

Can you try again with -v ?

That said, I see no good reason for tying that json field to the verbose mode, so I'd suggest outputting it unconditionally.

@sbidoul sbidoul added C: editable Editable installations C: list/show 'pip list' or 'pip show' labels Jan 28, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Jan 28, 2020
@sbidoul sbidoul added the type: enhancement Improvements to functionality label Jan 28, 2020
@ThimoNeubauer
Copy link
Author

Indeed with "-v" the output contains the locations of all packages:

PS E:\temp> .\foo\Scripts\python.exe -m pip list --format json --verbose
[{"name": "pip", "version": "20.0.2", "location": "e:\\temp\\foo\\lib\\site-packages", "installer": "pip"}, {"name": "setuptools", "version": "41.2.0", "location": "e:\\temp\\foo\\lib\\site-packages", "installer": "pip"}, {"name": "six", "version": "1.14.0", "location": "e:\\temp\\six-1.14.0", "installer": ""}]

But yes: fixing the non-verbose behavior would be a superior solution :-)

@sbidoul
Copy link
Member

sbidoul commented Feb 1, 2020

WIP PR in #7670

@sbidoul
Copy link
Member

sbidoul commented Jul 31, 2021

@ThimoNeubauer if you are still interested in this issue, you may want to test a possible solution in #10249

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: editable Editable installations C: list/show 'pip list' or 'pip show' type: enhancement Improvements to functionality
Projects
None yet
2 participants