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

Add option to list config files with pip config #8096

Merged
merged 6 commits into from
Jul 2, 2020

Conversation

deveshks
Copy link
Contributor

@deveshks deveshks commented Apr 20, 2020

Fixes and closes #6741

Add option to list config files per variant and whether they actually exist

$ pip config list-files
env:
global:
  /Library/Application Support/pip/pip.conf, exists: False 
site:
  /Users/devesh/pip/.env/pip.conf, exists: True 
user:
  /Users/devesh/.pip/pip.conf, exists: False 
  /Users/devesh/.config/pip/pip.conf, exists: False 

This is a preliminary output, but we need to decide on some things before we finalize something

Edit: An updated format with all values for a config file listed under it is now added:

If PIP_CONFIG_FILE is set

$ pip config debug
env_var:
  PIP_CONFIG_FILE='/Users/devesh/Desktop/pip.cfg'
  PIP_DEFAULT_TIMEOUT='60'
env:
  /Users/devesh/Desktop/pip.cfg, exists: True
    global.timeout: 60
    global.index-url: https://download.zope.org/ppix
global:
  /Library/Application Support/pip/pip.conf, exists: True
    global.timeout: 60
    freeze.timeout: 10
site:
  /Users/devesh/pip/.env/pip.conf, exists: True
    global.no-cache-dir: false
    install.no-compile: no
    install.no-warn-script-location: false

If PIP_CONFIG_FILE is not set:

$ pip config debug
env_var:
  PIP_DEFAULT_TIMEOUT='60'
env:
global:
  /Library/Application Support/pip/pip.conf, exists: True
    global.timeout: 60
    freeze.timeout: 10
site:
  /Users/devesh/pip/.env/pip.conf, exists: True
    global.no-cache-dir: false
    install.no-compile: no
    install.no-warn-script-location: false
    a.b: 1
user:
  /Users/devesh/.pip/pip.conf, exists: False
  /Users/devesh/.config/pip/pip.conf, exists: True
    global.find-links: 
    http://download.example.com
    install.find-links: 
    http://mirror1.example.com
    http://mirror2.example.com
    install.trusted-host: 
    http://mirror1.example.com
    http://mirror2.example.com

@deveshks
Copy link
Contributor Author

deveshks commented May 2, 2020

To move the PR ahead, I have implemented the first suggestion provided in #6741 (comment). (Naming the command as pip config debug and following it's output.

The output now looks like:

$ pip config debug
env:
global:
  /Library/Application Support/pip/pip.conf, exists: False 
site:
  /Users/devesh/pip/.env/pip.conf, exists: True 
    install.timeout: 10 
user:
  /Users/devesh/.pip/pip.conf, exists: False 
  /Users/devesh/.config/pip/pip.conf, exists: True 
    global.timeout: 15 
    global.index-url: https://private_pypi.com/simple/ 

Hi @xavfernandez ,

The only thing missing in the output in your example which I implemented in the latest commit is PIP_INDEX_URL: https://test.pypi.org/simple/ under env: in the original example. Where do I look for this key-value pair to be shown under env?

@deveshks
Copy link
Contributor Author

Hi @xavfernandez , @pradyunsg

Any suggestions on the next steps to do here, in order to move this PR ahead and get this approved/merged, especially w.r.t #8096 (comment) are welcome.

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, although the naming of the command and functions should be updated, to more directly reflect what they're for. :)

news/6741.feature Outdated Show resolved Hide resolved
news/6741.feature Outdated Show resolved Hide resolved
@deveshks deveshks force-pushed the list-config-files branch 4 times, most recently from 30bc04a to 39432a6 Compare May 31, 2020 20:36
@deveshks deveshks requested a review from pradyunsg May 31, 2020 20:44
@deveshks deveshks force-pushed the list-config-files branch 7 times, most recently from f8a44e9 to 9ed61dc Compare June 1, 2020 12:19
@deveshks
Copy link
Contributor Author

deveshks commented Jun 1, 2020

I have also gone ahead and added tests for this feature for everything except to test for system-wide configuration file which falls under global.

I think we can neither write to system-wide files which might have permissions defined in a way that the tox virtualenv cannot write to those locations, and we cannot patch those files as well since pip config commands runs inside a subprocess.

Any suggestions on if there are other ways to achieve this is welcome.

The current output for the command can be found at the PR description.

@deveshks deveshks force-pushed the list-config-files branch 2 times, most recently from 7c71c59 to 47c85f7 Compare June 1, 2020 14:10
@deveshks
Copy link
Contributor Author

deveshks commented Jun 3, 2020

Hi @pradyunsg

This should be good to go except a test for verifying set global options inside a virtualenv, which I am unsure how to do (#8096 (comment)).

Also the Travis CI has passed, but the status is stuck at Pending 😞

@deveshks
Copy link
Contributor Author

deveshks commented Jun 9, 2020

I added a test in 84d6719 which verifies that the global configuration file is correctly identified for different platforms.

With that, I think that this PR is implementation complete, and should be ready for further reviews.

@deveshks
Copy link
Contributor Author

Okay so the CI is green now too after rebasing to current master as well. The PR is ready for further reviews and approval/merge.

@deveshks
Copy link
Contributor Author

Hi @xavfernandez

I think this PR is feature complete, and I would really appreciate if you could take a look at this, and provide further reviews.

Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it 👍

Ideally, we should also help identify invalid/unknown options or environment variable, something like:

$ PIP_TOTO=titi pip config debug
env_var:
  PIP_TOTO='titi'
env:
global:
  /etc/xdg/pip/pip.conf, exists: False
  /etc/pip.conf, exists: False
site:
  /home/xafer/.virtualenvs/pip/pip.conf, exists: False
user:
  /home/xafer/.pip/pip.conf, exists: True
    global.disable-pip-version-check: 1
    global.timout: 10

PIP_TOTO is not a known configuration environment variable
global.timout is not a known configuration key (did you mean global.timeout ?)

but this can definitely happen in a followup PR :)

tests/functional/test_configuration.py Show resolved Hide resolved
tests/functional/test_configuration.py Show resolved Hide resolved
tests/functional/test_configuration.py Show resolved Hide resolved
tests/functional/test_configuration.py Show resolved Hide resolved
@deveshks
Copy link
Contributor Author

Thanks @xavfernandez . This should be ready to merge.

Ideally, we should also help identify invalid/unknown options or environment variable, something like:

$ PIP_TOTO=titi pip config debug
env_var:
  PIP_TOTO='titi'
env:
global:
  /etc/xdg/pip/pip.conf, exists: False
  /etc/pip.conf, exists: False
site:
  /home/xafer/.virtualenvs/pip/pip.conf, exists: False
user:
  /home/xafer/.pip/pip.conf, exists: True
    global.disable-pip-version-check: 1
    global.timout: 10

PIP_TOTO is not a known configuration environment variable
global.timout is not a known configuration key (did you mean global.timeout ?)

but this can definitely happen in a followup PR :)

That's a very good idea, and I think this can definitely be handled in a separate issue/PR.

@deveshks
Copy link
Contributor Author

Hi @pradyunsg

We should be good to merge this unless there are more reviews needed here, post this I will work on #8096 (comment)

@xavfernandez xavfernandez merged commit 09f9b00 into pypa:master Jul 2, 2020
@xavfernandez
Copy link
Member

Thanks a lot @deveshks 👍

@deveshks deveshks deleted the list-config-files branch July 2, 2020 13:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List configuration files
4 participants