-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Apologies if this has been discussed elsewhere, cursory searching didn't turn anything up.
https://pip.pypa.io/en/stable/topics/configuration/#configuration-files
The stated config priority is SITE > USER > GLOBAL, with global values being overridden by user values being overridden by site values.
What are the use cases for a site config file which overrides the system-wide user config? It makes sense that a virtual environment might need a specific config overriding any system-wide global and user config. This is reflected by the various paths used (from global system, to user-specific, to venv specific):
$ pip config list -v
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '~/.pip/pip.conf'
For variant 'user', will try loading '~/.config/pip/pip.conf'
For variant 'site', will try loading '[venv]/pip.conf'
...
However, at least on Ubuntu, when outside of a virtual environment, the file hierarchy seemingly departs from the intended config priorities.
$ pip config list -v
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '~/.pip/pip.conf'
For variant 'user', will try loading '~/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'
...
/usr/pip.conf
is not writeable by the user (like a virtualenv config would be) nor overrideable except with PIP_CONFIG_FILE
and furthermore overrides any user config.
This is made worse when distributors deploy a config that should be system global config (overrideable) to this site config path /usr/pip.conf (like nvidia-pyindex
does).
Should pip site config point to a path like /usr/pip.conf
or somewhere else, or nowhere at all, when not in a virtual environment?
Is this just a problem with Ubuntu pip? Or with distributors that abuse the site config?
An alternative order of priority could be USER > SITE > GLOBAL but this precludes the virtual environment use case..