Skip to content
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

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

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

bkjones opened this issue Jun 20, 2011 · 32 comments
Labels
auto-locked Outdated issues that have been locked by automation C: configuration Configuration management and loading type: enhancement Improvements to functionality

Comments

@bkjones
Copy link

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!

@pnasrat
Copy link
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.

@jezdez
Copy link
Member

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
Copy link
Author

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?

@pnasrat
Copy link
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.

@ghost ghost assigned pnasrat Jun 29, 2011
@jezdez
Copy link
Member

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
Copy link
Author

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.

@jezdez
Copy link
Member

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
Copy link

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.

@kennethreitz
Copy link
Contributor

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

@jezdez
Copy link
Member

jezdez commented Jun 29, 2011

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

@jezdez
Copy link
Member

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.

@kennethreitz
Copy link
Contributor

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

@jezdez
Copy link
Member

jezdez commented Jun 29, 2011

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

@kennethreitz
Copy link
Contributor

✨ 🍰 ✨

@pnasrat
Copy link
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
Copy link
Author

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.

@skull-squadron
Copy link

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
Copy link

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.

@skull-squadron
Copy link

@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.

@akvadrako
Copy link

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.

@ceocoder
Copy link

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

@JamesHarrison
Copy link

+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).

@pnasrat
Copy link
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 added a commit to dgladkov/pip that referenced this issue Mar 18, 2013
dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013
dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013
dgladkov added a commit to dgladkov/pip that referenced this issue Mar 18, 2013
@trbs
Copy link

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
Copy link

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
Copy link

mxmader commented Mar 19, 2014

i would also like to see this tested/merged.

@gtmtech
Copy link

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
Copy link

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.

@miketheman
Copy link
Member

@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
Copy link

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"

@Ivoz
Copy link
Contributor

Ivoz commented May 15, 2014

@slafs we're working on this in #1733

r1chardj0n3s added a commit to r1chardj0n3s/pip that referenced this issue Aug 22, 2014
* 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
gforsyth added a commit to gforsyth/xonsh that referenced this issue Oct 21, 2015
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
@codyaray
Copy link

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.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: configuration Configuration management and loading type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests