-
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
Standardize our Paths #1733
Comments
Proposals: (WIP, please edit / comment) ConfigurationWindows:
Nix:
CacheWindows: Nix:
|
for historical reference #582 (XDG compliance for linux) was temporarily merged 2 years ago (but reverted right before release) because the migration logic it included was considered too dangerous. so think about migration when considering this. |
To confirm, this is replacing the current single file
Actually, the location logic is a bit messy to get right in a cross-platform way. Rather than do it for pip and no-one else benefit, maybe we should create a separate "stdpaths" module on PyPI and then vendor it in pip. I'd be happy to provide the Windows knowledge for something like this. (I seem to remember that there's a module around somewhere that tries to do this, but it requires pywin32 and it seems fairly unmaintained - I never got a response to a patch I submitted to use ctypes - so starting from scratch may be better than using that). |
Creating a stdpaths module sounds like a great idea to me. I think this is something that a lot of projects get "wrong" (as we currently do) especially in the Windows sense. |
I started https://github.com/pypa/stdpaths and set it up in RTD/PyPI/Travis-CI. It doesn't have any actual code and I have some ideas for what it should look like. However I need to run out for a little bit so I had to stop. |
@dstufft cool. I'll keep an eye on it and add PRs as appropriate. May do a PR straight up for some code to get the Windows standard locations via ctypes. That might be useful to expose directly, or just to use internally, we can thrash that out. |
Awesome. I'm researching XDG which is the "standard" on Linux. Maybe @glyph could advise for how to handle on OSX.
|
@pfmoore thanks for the tip on Roaming. I'm cursorily knowledgeable of the Windows conf paths, not as much as Linux. For the moment, I'm listing just the best place to put things to use as a reference. My current idea would be to read each file in order, and simply replac e values present in previous files read with the ones in the newer one. So a priority order; The user's ~/.config/pip/pip.conf would replace any confliciting values in /etc/pip.conf. Lastly, IMHO pip should never use anything requiring ctypes or ffi, so I'd be against using that to find out Windows stuff, even if the resulting method of finding stuff was less 'correct'. @qwcode TBH I'd do something simpler than that PR - just look for the new config file path, and fall back to the old if it's not there, rather than trying to do any copying. |
@dstufft I think it's OK to just use |
@Ivoz yeah, we can thrash out detailed locations as we go. I'm not sure "replace previous" is actually sufficiently well defined. Think about find-links, which can be specified multiple times in one file. Suppose location 1 says find-links A, B. Then location 2 wants to add C - should it have to specify A and B as well (and so need to be kept up to date as location 1 changes)? Then if location 3 wants to say "actually no, I want no find-links at all, how does it do that? Specifying nothing won't work as it would mean "use what the last location said". Obviously this is ridiculously unlikely to happen, and "Don't do that" is probably the best answer. But we need at a minimum to document the behaviour. Also, why do you object to ctypes? To get the standard locations on Windows requires either ctypes or a C extension, and I'd have thought a C extension was much worse than ctypes. If your problem is that ctypes has the potential for segfaults and/or may not be present, that is 100% not the case for something that's Windows-only. It's quite possible to write code using ctypes to access the Windows API and it'll be perfectly robust (as far as I'm aware). If you know of something specific that concerns you, let me know. |
Aah! Here we go, official API confirmation, sort of:
Pip could potentially have an optional pyobjc import and just re-implement this in Python. |
Yea anything that requires a C extension is right out, but optional C-exts are ok and if we can do it with ctypes reasonably (as in the Windows case it sounds like) just use that. |
Oh hey, look what I found https://github.com/ActiveState/appdirs |
So I've looked at appdirs and figured out if we use it, what the paths will be on the various systems. In the below lists *nix basically means any non Windows or OSX machines. All of the Windows paths are for Vista/Win7 and the Windows XP paths are whatever the Vista/Win7 paths would correlate too. So I guess the question is, do these paths look accurate? The XDG ones look reasonable to me, as does the OSX ones (but I'm not real sure about. @glyph said bundle id should be a reverse domain name, whereas AppDir is using "app name". Though we could pass in The Windows ones I have no idea on, they look reasonable to me but I have no idea about the distinctions between Local and Roaming and ProgramData and such, and there's also the sticking point that the location for the machine configuration file on Windows is apparently broken on Vista. Hopefully @pfmoore can give some guidance here! It's also important to note that appdirs will expand the environment varaibles out for XDG, however it is just using Machine Specific Configuration File
User Specific Configuration File
User Specific Cache Directory
User Specific Log Directory
XDG Default ValuesOn *nix the directories are configurable using environment variables, these environment variables have defaults which are:
|
Forgot to mention, the above post is aiming to figure out if we can just reuse appdirs instead of writing our own! So hopefully we can audit those values and determine if they look correct for us. |
Well, we could. But I kind of feel like that makes editing the user configuration file kind of annoying? I'm not sure it makes sense at all on Windows since that is keyed by Vendor + app name (so it's Is that domain thing even really a convention on OSX? My |
Perhaps stealing from Windows here, it makes sense to do |
Remember that this is a platform with at least a 26-year history at this point. Some things don't use the latest conventions ;-).
So, first of all, this is easy to fix. Here are some ideas about how to make this transparent, and more convenient than the current scheme:
Also, maybe consider that if things actually work by default, users won't have to screw around with INI files quite so much? ;-) Consider that every time a user has to edit a config file, there's been some kind of failure. See, for example, this apparently timeless essay by Havoc Pennington. |
Sure, but I don't think the App Store, iCloud, and AirPort (three random Apple apps which don't use
I like this
So I agree that we should get to a point where a user needing to edit their config file to get what we consider "best practices" and the most reasonable behaviors should be considered a failure of design rather than the status quo. However I don't think we'll be able to avoid ever opening the configuration file so it's still important to me to not make that annoying (However the I actually went ahead and registered the domain pypa.io and sent an email to the pypa-dev mailing list about it. Perhaps we can end up with pip.pypa.io, virtualenv.pypa.io, etc which we can then use io.pypa.pip as our app name in that case. |
Qt uses the following format: http://qt-project.org/doc/qt-5/QSettings.html#platform-specific-notes -- in our case this would be |
I'd prefer I really like git's practice for configuration setting; i.e its |
@dstufft I don't think it's right to use local for some things and roaming for others. I'm not sure I've ever seen an app that does that. I'd probably put them all in Program Data and Application Data are both hidden, so there are the same problems with both. In practice, those problems tend to be relatively minimal on Windows 7, but they can be distinctly irritating on earlier versions. Also, earlier versions had spaces in the directory names, which also made for an annoying user experience. (I'm not even sure there was a "program data" location in XP and earlier, so that may be an issue). Generally, these folders are probably the right thing to use, but they are intended to hold files that are managed by an application, not by user editing (imagine a "preferences" dialog in a GUI app). So there will still be a "user experience" issue to consider, but it's consistent with other applications. I'd like to see something similar to BTW, for preciseness, it would be better to talk in terms of CSIDLs on Windows - see http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx for details. But that's pretty horrible for non-Windows people, so I'm happy to keep translating :-) I'm assuming we're talking about
I'm not enamoured of the extra |
Hmm, after writing all that, I see that the original suggestions were direct from the definitions in ``appdirs`. Sigh. I should have read the original comment more carefully. Summary - no, I don't like the choices made by |
@pfmoore Whoops, I haven't used Windows in awhile so I just guessed that |
FWIW I'm not married to appdirs, the functionality is simple enough that it's not horrible to make our own. |
I think that moving to the appdirs tracker would be a good start. Who wants to file an issue? :) |
FTR, I'm -0 on using the XDG spec, it's a super weird standard that only select packages seem to follow, and then only partially at best (e.g. I can get behind using |
@jezdez I would prefer to just follow the standard as-is, flaws and all, because https://xkcd.com/927/ - but your observation is correct, few packages honor |
We decided to do both, we'll support |
Given XDG is for X Desktop Group, pip not being a desktop application per se, and global configuration files being stored generally in |
The only deviation from the above conversation in what I've implemented is that I've not taken @pfmoore's advice and I'm looking for the config in a |
We need to pick one and use it. Right now the cache directory is not using a vendor directory, and your PR does. Whichever way we go we need to be consistent. |
My PC has applications in But it's basically a bikeshed issue, and I agree with @dstufft, consistency is the key thing. I assume the cache directory is #1748 which is merged, so I'd say go with no vendor label rather than having to revisit that. |
okie dokie @pfmoore I'll mod the PR :) |
To be clear (as noted on IRC) I'm suggesting basically what @Ivoz said up above:
So we have Vendor = (omitted) and Application = "Pip". On my PC, ProgramData is C:\ProgramData, USERPROFILE is C:\Users and APPDATA is %USERPROFILE%\AppData\Roaming. Note that the download cache (user_cache_dir) uses %LOCALAPPDATA%, not %APPDATA% (%USERPROFILE\AppData\Local). This is deliberate - config wants to be included in the roaming profile, but cache data doesn't. |
Just noticed that #1978 is only looking at |
I think the only thing left for this particular ticket is the default log file, and the user config. |
This is done now! |
Eh, it's spread over a bunch of PRs, mostly recently #2021. |
I am running into build failures on my company's locked-down build machines due to this code, when building Chromium. The traceback is: 2015-10-19 09:44:38 gobuilds.Compile : Traceback (most recent call last): I have tried plumbing through the various appdata-related environment variables to the environment of the script, as well as confirming that the directories all exist and have rwx permissions. Is there some way that I can set an environment variable to have pip not write any values to local directories, so as to prevent the code from even trying to retrieve CSIDL_COMMON_APPDATA and CSIDL_LOCAL_APPDATA? |
@grossag Not sure about your issue (not used to windows), but you could try with latest pip: |
We should follow system conventions for where we look for config files, cache files, log files, etc.
The text was updated successfully, but these errors were encountered: