-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Provide a global (system-wide) config file. #309
Comments
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 %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? |
@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 |
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 |
|
@kennethreitz You mean |
@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 |
|
@kennethreitz Excellent, this is what I needed, thanks! Let's go with |
✨ 🍰 ✨ |
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: System-wideHKEY_LOCAL_MACHINE\SOFTWARE\Python\PyPI\pip Per-userHKEY_CURRENT_USER\SOFTWARE\Python\PyPI\pip Possibly useful starting-point: |
@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). |
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. 👍 |
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
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
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? |
would really like to see this too. For now i just made my 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 |
* 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 pypa#309
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@2b5029c5
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. |
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!
The text was updated successfully, but these errors were encountered: