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

Already on GitHub? Sign in to your account

Provide a global (system-wide) config file. #309

Closed
bkjones opened this Issue Jun 20, 2011 · 32 comments

Comments

Projects
None yet

bkjones commented Jun 20, 2011

I have an internal PyPI implementation, and I'd like to configure pip system-wide to try getting packages from that internal location before heading out to PyPI. Right now, the only ways I can think to do this involve distributing default config files for every user, or setting environment variables in all of the global shell configuration files. Either method is, at best, messy. A global config file should allow an admin to specify default configuration options for every user on the system, and if the user needs to override these options, they can point pip to their personal config file, or (for more stubborn users) set their own env variables in their personal shell init files.

If there is another recommended way to do this, please let me know!

Contributor

pnasrat commented Jun 20, 2011

I think this is pretty reasonable, and makes a lot of sense from the use case of a systems managed installer.

For *nix systems it's fairly obvious where the file should go, I'm a little less certain about windows.

Contributor

jezdez commented Jun 29, 2011

If you can define "a global config file" in code, for all supported platforms, I'd be happy to add that to the list of files pip reads during startup.

bkjones commented Jun 29, 2011

I'm not sure what this means. All I'm after is getting pip to look for a pip.conf or pip.ini file in a standard location for system-wide defaults before referring to $HOME/.pip/pip.conf or %HOME\pip\pip.ini, which would have the ability to override the global settings, not unlike other tools that employ the same pattern. I'm not talking about a new file format or anything. I'm also not talking about requiring that this global file exist, just like pip doesn't require you to have a personal config file in $HOME. I just want the option of putting a pip.conf file in a known location and having pip use it.

Given that, it's unclear what is meant by defining a global config file 'in code'. Can you clarify that?

Contributor

pnasrat commented Jun 29, 2011

@bkjones I'm going to try and come up with a patch to address this issue, taking into account @jezdez's concerns. I think I understand what he's asking and can discuss on IRC with him further.

@pnasrat pnasrat was assigned Jun 29, 2011

Contributor

jezdez commented Jun 29, 2011

@bkjones I simply don't know what the canonical file system locations are for "global config file". It's easy enough for Linux/Unix. But this won't work for Mac OS and Windows (and its various versions). I'm not saying this isn't a good idea, just that implementing this half-assed is a bad idea.

bkjones commented Jun 29, 2011

@jezdez - agreed -- it should be done following best practices where they exist. I can't profess that knowledge either. I can probably help in doing the research to get us there. For Mac OS, is there some reason we can't use /etc/pip/pip.conf for Linux/UNIX and Mac OS? Seems like most things I install treat OS X like Linux in terms of config locations. Only building from source with the proper ./configure flags would change the config file locations.

Still, there's convention, and there's "what they'd have you do", so I'll try to find some authoritative source of information on that for each platform.

Contributor

jezdez commented Jun 29, 2011

@bkjones On Mac OS the /etc dir is strictly for the OS (actually is a symlink to /private/etc), AFAIK. Users usually store their personally configuration files in ~/Library/Preferences. Since there is also a /Library/Preferences directory I assume this is supposed to be use for "global preferences". But it seems weird to recommend ~/.pip/pip.conf for user files, and /Library for global ones. So what if we'd put it in /usr/local/etc/pip.conf on Mac OS?

adamv commented Jun 29, 2011

Note that on a brand hew OS X installation there is no /usr/local (though I haven't checked this in some time), and apps like AirFoil and other things installed via .pkg can munge up the permissions on /usr/local such that parts of it are owned by root.

So be aware that using /usr/local can have support issues on OS X.

Contributor

kennethreitz commented Jun 29, 2011

/etc/pip.conf seems like a good spot for OSX to me.

Contributor

jezdez commented Jun 29, 2011

@kennethreitz You mean /private/etc/pip.conf? -1

Contributor

jezdez commented Jun 29, 2011

@adamv Yeah, that's true. But on the other hand it's also a fairly small use case to add a global config in the first place. So having an admin create /usr/local/etc doesn't sound like too much to ask for.

Contributor

kennethreitz commented Jun 29, 2011

$ man hier says /etc/ is for "system configuration files and scripts", which this would be, no?

Contributor

jezdez commented Jun 29, 2011

@kennethreitz Excellent, this is what I needed, thanks! Let's go with /etc/pip.conf.

Contributor

kennethreitz commented Jun 29, 2011

🍰

Contributor

pnasrat commented Jun 29, 2011

I'd personally rather $SYSCONFDIR/pip/pip.conf in case we want to add multiple files. I've been poking at the win32 side of things to see if we can get something standardized easily.

As I said I'm happy to put a patch together, with tests for the current config stuff, which when I took a look didn't have coverage.

bkjones commented Jun 29, 2011

I'd agree w/ @pnasrat - all software w/ a file in /etc eventually evolves to the point of moving that file to a /etc/something directory. Just do it up front.

I don't have a Windows box, however something like this seems the Redmond way:

System-wide

HKEY_LOCAL_MACHINE\SOFTWARE\Python\PyPI\pip

Per-user

HKEY_CURRENT_USER\SOFTWARE\Python\PyPI\pip

Possibly useful starting-point:
http://code.activestate.com/recipes/66011-reading-from-and-writing-to-the-windows-registry/

holmboe commented Feb 21, 2012

@steakknife I would propose to keep the configuration in a file. It would require additional code in pip to read/write the configuration if it would be stored inside the Windows registry. Is there any other benefits to this, that you see?

I propose to put it in %ALLUSERSPROFILE%\Application Data\pip\pip.ini.

See http://stackoverflow.com/questions/750698/where-to-put-global-application-data-in-vista for some discussion on this path.

@holmboe: Wow, I didn't even remember writing that. Clearly less effort is always superior, and I could give a trollbait about Microshit either way.

Go for it.

any update? I would rather see pip read /usr/lib/python/distutils/distutils.cfg just like everything else, but any global config file would be nice.

FWIW - I'd love to see a /etc/pip/pip.conf (better than teaching puppet to place a ~/.pip/pip.conf for all users)

+1 for this; this is a blocker for Puppet configurations that need configuration for pip (since pip doesn't follow http_proxy/https_proxy environment variables, for instance). If OSX and Win32 have definitions too vague to agree on for config paths, can the clear-cut Linux OSes be covered at the least? (ie the suggested /etc/pip(.conf|/pip.conf) path).

Contributor

pnasrat commented Feb 14, 2013

I'm pretty sure pip works with http_proxy other than for eg subversion, etc http://www.laurii.info/2010/11/using-pip-behind-proxy/

testing http_proxy=http://localhost:3128 pip install ipython with no proxy errors out which I expect.

Also just assuming /etc doesn't work with eg virtualenvs, etc. We'll probably get to something but not before next release

@dgladkov dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013

@dgladkov dgladkov #309 add global config file support 2b5029c

@dgladkov dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013

@dgladkov dgladkov #309 update docs cc5af09

@dgladkov dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013

@dgladkov dgladkov #309 update docs precedense section 0e7c60d

@dgladkov dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013

@dgladkov dgladkov #309 changed "global" to "system-wide" to avoid confision with "[glob…
…al]"
f2446a3

@frabcus frabcus referenced this issue in sensiblecodeio/custard Mar 25, 2013

Closed

New images should make it easier to use pip #144

trbs commented Jul 17, 2013

Any update on this / is anything holding things back to get a solution merged ?

Currently PIP_CONFIG_FILE is a possible work around for doing configuration management.

seocam commented Mar 7, 2014

This feature would be very helpful to create base images pre-configured to use your mirror instead of main one in case you have a provider or something like that.

👍

mxmader commented Mar 19, 2014

i would also like to see this tested/merged.

gtmtech commented Mar 27, 2014

I was looking for something like this - is it done yet, I can't tell? Otherwise +1 , even though its nearly 3 years old O.o

javiplx commented Apr 8, 2014

Maybe I got lost at some point, but I see a comment in this thread from three years ago

Excellent, this is what I needed, thanks! Let's go with /etc/pip.conf

But in my rhel6.2 it does not work. For the impatient, search on pip/baseparser.py and on ConfigOptionParser.get_config_files and modify the return output to fit your needs.

For me

return ["/etc/pip.ini",default_config_file]

works without any problem. I'll maybe prepare a PR for this, although it will probably take longer fork and submit than finding this hack.

@pnasrat Has there been any further review on this, or anything similar cropped up in the meantime?
This is a very useful feature, especially in the days of configuration management, allowing a system-level default prevents users from ever needing to think about anything other than using the pip interface.

slafs commented May 15, 2014

would really like to see this too.

For now i just made my /etc/pip.conf and I globally set export PIP_CONFIG_FILE=/etc/pip.conf in /etc/profile. This overrides user based conf files though. Which is fine with my scenario since none of the users have their own ~/.pip/pip.conf file.

A quick and nice fix for this would be to allow multiple values on this variable (like in PIP_FIND_LINKS for example). Then one could set the variable to something like this export PIP_CONFIG_FILE="/etc/pip.conf $HOME/.pip/pip.conf"

Member

Ivoz commented May 15, 2014

@slafs we're working on this in #1733

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 15, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
64eda0f

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 15, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
192cbe5

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 15, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
df61f12

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 15, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
3c8dd3f

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 18, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
cd9ae65

@r1chardj0n3s r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 22, 2014

@r1chardj0n3s r1chardj0n3s Implement site-wide configuration settings
* add site_config_dirs() to appdirs to determine locations across OSes
* add system_config_files to locations.py
* add system_config_files to get_config_files() and re-order files entries to correct precedence
* document changes to configuration files in user guide

Closes #309
aedca3c

@dstufft dstufft closed this in #1978 Aug 22, 2014

@gforsyth gforsyth added a commit to gforsyth/xonsh that referenced this issue Oct 21, 2015

@gforsyth gforsyth add support for windows system-wide xonshrc
pypa/pip had a similar conversation about this a few years ago
(see: pypa/pip#309) and determined that
placing global configuration files in `%ALLUSERSPROFILE%\Application
Data` was the best solution without messing around with the registry.
Following their lead on this, specifically from
pypa/pip@2b5029c
67a2e92

codyaray commented Nov 4, 2016

Just tested in pip 9.0.0 and /etc/pip.conf works. Probably works earlier too, but I didn't see anything conclusive about what worked in this thread.

@pnasrat pnasrat was unassigned by codyaray Nov 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment