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!
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.
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.
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 %HOMEpippip.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?
@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.
@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.
@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.
@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?
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.
/etc/pip.conf
seems like a good spot for OSX to me.
@kennethreitz You mean /private/etc/pip.conf
? -1
@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.
$ man hier
says /etc/
is for "system configuration files and scripts", which this would be, no?
@kennethreitz Excellent, this is what I needed, thanks! Let's go with /etc/pip.conf
.
:sparkles: :cake: :sparkles:
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.
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:
HKEY_LOCAL_MACHINESOFTWAREPythonPyPIpip
HKEY_CURRENT_USERSOFTWAREPythonPyPIpip
Possibly useful starting-point:
http://code.activestate.com/recipes/66011-reading-from-and-writing-to-the-windows-registry/
@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 Datapippip.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).
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
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.
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.
:+1:
i would also like to see this tested/merged.
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
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.
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"
@slafs we're working on this in https://github.com/pypa/pip/issues/1733
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.
Most helpful comment
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.