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 config` should support `add` and `remove` commands

See original GitHub issue

What’s the problem this feature will solve?

I use the pip config command quite a lot, but it does not allow me to add multiple entries to trusted-hosts or to remove a value from the config. This would greatly improve usability for me.

Describe the solution you’d like

Being able to add a value to trusted hosts or index-url with:

pip config add global.trusted-host artifactory.mycompany.com
pip config remove global.trusted-host artifactory.mycompany.com

Alternative Solutions

Currently I just use preexisting configs and keep swapping them out. However, this is an interim solution that is really not helping. Our company has a tight lockdown on the network, and when we switch to external networks, we need to remove the index-urls and add external ones to trusted hosts. We would rather not directly download from pypi or files.pythonhosted.org on company VPN.

Additionally, this is very different from pip config set which sets and unsets absolute values. In this scenario, I could engineer a mix of values from separate configs. This would allow me to swap out registries and add them back without macguyvering solutions like I do today.

Additional context

This is why I had originally created the following issues: #7803 and #7804

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
deveshkscommented, May 19, 2020

If I understand the use-case correctly, You want to be able to set multiple values in pip config for a key, or add to existing values.

With set, you can only provide one value, and that either creates a new value, or replaces the existing one, as seen below.

$ pip config set global.trusted-host artifactory1.mycompany1.com
Writing to /Users/devesh/.config/pip/pip.conf

$ cat /Users/devesh/.config/pip/pip.conf
[global]
trusted-host = artifactory1.mycompany1.com

$ pip config set global.trusted-host artifactory2.mycompany2.com
Writing to /Users/devesh/.config/pip/pip.conf

$ cat /Users/devesh/.config/pip/pip.conf
[global]
trusted-host = artifactory2.mycompany2.com

So in your case, doing pip config add global.trusted-host artifactory1.mycompany1.com and pip config add global.trusted-host artifactory2.mycompany1.com will give you.

$ cat /Users/devesh/.config/pip/pip.conf
[global]
trusted-host = artifactory1.mycompany1.com
    artifactory2.mycompany2.com

And with unset, we get rid of the all option presents.

$ pip config get global.trusted-host
artifactory1.mycompany1.com
artifactory2.mycompany2.com
(venv) DeveshSinghMac:~ devesh$ cat /Users/devesh/.config/pip/pip.conf
[global]
trusted-host = artifactory1.mycompany1.com
    artifactory2.mycompany2.com
(venv) DeveshSinghMac:~ devesh$ pip config unset global.trusted-host
Writing to /Users/devesh/.config/pip/pip.conf
(venv) DeveshSinghMac:~ devesh$ cat /Users/devesh/.config/pip/pip.conf
(venv) DeveshSinghMac:~ devesh$ 

But in your case, pip config remove global.trusted-host artifactory1.mycompany1.com and pip config remove global.trusted-host artifactory2.mycompany1.com will get rid of options one by one if present (perhaps if there is only one remaining, we should get rid of [global] section itself)

1reaction
potiukcommented, Apr 13, 2022

BUMP. My company would also greatly benefit from this feature.

Re your bump: @aamailhot

As a person interested in funding open source (I am not pip maintainer). Since your company would “greatly benefit” I wonder how much your company would like to pay the maintainers for their voluntary work ?

I am currently discussing in the open-source communities ways of funding the OSS efffort and I am interested in hearing what is possible.

Did you consider for example Github Sponsorship? Would that be an option for your company? How much of a regular sponsorship wouldl you see as worth the “great benefit” ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip config - pip documentation v22.3.1
unset: Unset the value associated with command.option. debug: List the configuration files and values defined under them. Configuration keys should be dot ...
Read more >
PIP Commands – A Simple Guide - Finxter
In this section, we will look at how to install packages and manage dependencies using pip. pip install. To install packages on pip...
Read more >
Where is pip.conf in my Mac which Python was installed via ...
The above command will tell you where the pip is looking for the pip.conf file both for use ... you can simply create...
Read more >
User Guide — pip 8.1.1 documentation
pip allows you to set all command line option defaults in a standard ini style config file. The names and locations of the...
Read more >
Configure and use pip with CodeArtifact - AWS Documentation
If you cannot use the login command to configure pip , you can use pip config . Use the AWS CLI to fetch...
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