classification
Title: unify pydistutils.cfg and distutils.cfg and use .local
Type: feature request Stage:
Components: Distutils Versions: Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: Merwok, barry, doko, fwierzbicki, georg.brandl, lemburg, michael.foord, ned.deily, pitrou, r.david.murray, ronaldoussoren, tarek (12)
Priority: normal Keywords

Created on 2009-10-20 11:21 by tarek, last changed 2009-11-06 03:10 by Merwok.

Messages (22)
msg94272 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-20 11:21
[.]pydistutils.cfg will be deprecated in favor of a single
"distutils.cfg", located in .local/ alongside the files added for
example by the per user-site packages.
msg94279 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-10-20 14:39
Why is this? .local/ contains machine-installed files while
.pydistutils.cfg is edited by the user.
msg94281 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-20 14:55
That's what is returned by site.getuserbase()

(which uses PYTHONUSERBASE, and defaults to ~/.local)

PYTHONUSERBASE is the root of Python user-specific paths so it makes
sense to have all Python related files in there.

This came up with the discussion we had with others at Distutils-SIG

read this thread here for more info:
http://mail.python.org/pipermail/distutils-sig/2009-August/012865.html

[.]pypirc should probably go there too.
msg94282 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-10-20 15:03
> That's what is returned by site.getuserbase()
> 
> (which uses PYTHONUSERBASE, and defaults to ~/.local)

Well, that makes it the user-specific equivalent of /usr or /usr/local.
Do you put your configuration files in /usr/local ? Why put them
in .local ?

> PYTHONUSERBASE is the root of Python user-specific paths so it makes
> sense to have all Python related files in there.

That doesn't make sense actually, since .local isn't Python-specific. :)
msg94284 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-10-20 15:11
I've read the thread now and I think the original proposal of having a
~/.python was more sensible and more user-friendly.
msg94285 - (view) Author: R. David Murray (r.david.murray) Date: 2009-10-20 15:17
+1 to what Antoine said.
msg94287 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-20 15:21
> Well, that makes it the user-specific equivalent of /usr or /usr/local.
> Do you put your configuration files in /usr/local ? 
> Why put them in .local ?

The distutils.cfg file is located in the distutils package itself !

So the target is ~/.local/pythonX.X/site-packages/distutils/distutils.cfg

(sorry if that was unclear)

Now, I would totally agree to have a better ~/.NAME to reunite
user-specific *configuration* file for Python, but that would be yet
another directory for user-specific Python files.
msg94288 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-10-20 15:37
> The distutils.cfg file is located in the distutils package itself !
> 
> So the target is ~/.local/pythonX.X/site-packages/distutils/distutils.cfg

Ah, that's horrible. -1 to that.
Configuration files should be easily findable by skimming through the
dot-files in the user's directory. ~/.python fulfills that condition.
msg94289 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-20 15:50
I like ~/.python very much too (that was my initial proposal IIRC). 

I guess the best way to add this support is to provide a new api in
site.py, that returns this folder.

Distutils can move pypirc and distutils.cfg file there.

Now for the global distutils.cfg, if we want to have it somewhere else
that the distutils package directory itself, we would need a
"/etc/python" scheme for instance, that could be also added in site.py.

I don't know though how the latter would look under windows
msg94293 - (view) Author: Marc-Andre Lemburg (lemburg) Date: 2009-10-20 17:32
Tarek Ziadé wrote:
> 
> Tarek Ziadé <ziade.tarek@gmail.com> added the comment:
> 
> I like ~/.python very much too (that was my initial proposal IIRC). 

+1 on that name as well.

One thing to note though: it is well possible that a user uses
multiple Python versions. With just one such directory, all
versions would look in the same directory for the configuration
files and this could lead to incompatibilities, e.g. Python 2.7
might not like that Python 3.6 needs in some config file (for
whatever reason).

> Now for the global distutils.cfg, if we want to have it somewhere else
> that the distutils package directory itself, we would need a
> "/etc/python" scheme for instance, that could be also added in site.py.
>
> I don't know though how the latter would look under windows

I think Subversion get's this pretty right, so we might want
to follow their scheme:

http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1
msg94412 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-24 12:56
The subversion system looks pretty nice !

So here's a modified proposal that covers the python version as well.

= per user configuration files = 

 ~/.pythonMAJOR.MINOR

Examples:

~/.python2.7
~/.python3.1

On Windows, ~ will be replaced by APPDATA if founded in the environment.
 
== global configuration files ==


On Linux/Mac:

/etc/pythonMAJOR.MINOR

examples:

/etc/python2.7/
/etc/python3.1/

On Windows:

\All users\Application Data\PythonMAJORMINOR

(\All users\Application Data is specified by the Windows Registry)

examples:

\All users\Application Data\Python26
\All users\Application Data\Python31

== standard naming for configuration files ==

The files are all named "NAME.cfg", in all platforms.

== what gets in per-user configuration directory ==

- pypi.cfg
- distutils.cfg

== what gets in global configuration directory ==

- distutils.cfg

== apis added ==

in site.py:

- getuserconfig() : returns the per-user configuration directory
- getconfig(): returns the global configuration directory

(the names are following site.py naming style)
msg94507 - (view) Author: Georg Brandl (georg.brandl) Date: 2009-10-26 21:06
FYI, /etc/pythonX.Y (and /etc/python) are used by Debian; the former
contains site.py and sitecustomize.py, the latter a file called
debain_config.

I can't see how this could become a problem, but maybe someone else does.
msg94519 - (view) Author: Tarek Ziadé (tarek) Date: 2009-10-26 22:04
Thanks for the info Georges.

I am adding Matthias and Michael so they can give us their opinions for
their platforms (Debian/Ubuntu and Win)
msg94523 - (view) Author: Michael Foord (michael.foord) Date: 2009-10-26 22:12
Personally I'm uncomfortable with creating
yet-another-location-for-config-files.

As we now have is ~/.local/pythonX.Y I would reuse this.
msg94527 - (view) Author: Georg Brandl (georg.brandl) Date: 2009-10-26 22:28
But ~/.local is simply not the location for config files.
msg94530 - (view) Author: Michael Foord (michael.foord) Date: 2009-10-26 22:35
For Linux and Mac OS X put the config file wherever the 'right' place is
then, but we are starting to create a lot of new directories disparate
from the actual install. Oh well.

On Windows we create: %APPDATA%/Python/PythonX.Y/site-packages

If it is to no longer live inside distutils (which seems reasonable)
then on Windoze a 'good' place would seem to be: %APPDATA%/Python/PythonX.Y/

On Windows there is no 'right' place, the officially right place for the
system is probably the registry but I don't think many Python
programmers would thank you for that...
msg94531 - (view) Author: Michael Foord (michael.foord) Date: 2009-10-26 22:36
Noting of course that on IronPython it should be:
%APPDATA%/IronPython/PythonX.Y/

or wherever we decided in the end. :-)
msg94620 - (view) Author: Ned Deily (ned.deily) Date: 2009-10-28 09:40
/etc is definitely not the right place to put files for OS X framework 
builds; if necessary, an etc directory could be added under the 
framework version directory as a sibling of bin and lib.  It's also very 
un-OS X like to be putting things into ~/.python and ~/.local 
directories; the usual place would be in somewhere ~/Library, possibly 
~/Library/Application Support/Python or ~/Library/Frameworks.  Keep in 
mind that it's much more likely on OS X to not only have muitiple 
versions of Python installed but also more than one instance of the 
*same* version, for instance, on 10.6, an Apple-supplied 2.6.2 and a 
python.org 2.6.4.  Some thought should be given to locations for the 
files for Unix-style (non-framework) builds.

(Adding Ronald.)
msg94622 - (view) Author: Marc-Andre Lemburg (lemburg) Date: 2009-10-28 09:46
Ned Deily wrote:
> 
> Ned Deily <nad@acm.org> added the comment:
> 
> /etc is definitely not the right place to put files for OS X framework 
> builds; if necessary, an etc directory could be added under the 
> framework version directory as a sibling of bin and lib.  It's also very 
> un-OS X like to be putting things into ~/.python and ~/.local 
> directories; the usual place would be in somewhere ~/Library, possibly 
> ~/Library/Application Support/Python or ~/Library/Frameworks.  Keep in 
> mind that it's much more likely on OS X to not only have muitiple 
> versions of Python installed but also more than one instance of the 
> *same* version, for instance, on 10.6, an Apple-supplied 2.6.2 and a 
> python.org 2.6.4.  Some thought should be given to locations for the 
> files for Unix-style (non-framework) builds.
> 
> (Adding Ronald.)

I think there is a misunderstanding here: we're trying to find
places where distutils would look by default, not where it
would write files.

AFAIK, there is general agreement that when writing files,
Python should use the ~/.local/pythonX.X/ directory.

OTOH, searching for config files that the user creates and
puts in place is another story. Python and distutils only
need to be able to find these and the idea is to use platform
specific standard search paths for this, so that the user
can place those config files into places that feel right on
each platform.
msg94623 - (view) Author: Ned Deily (ned.deily) Date: 2009-10-28 10:24
I don't think there's a misunderstanding.  By "putting", I meant "reading" 
or "writing".  IMO, /etc is not the place on OS X to be looking for 
python-related configuration files, certainly not for framework installs.  
Likewise for ~/.python and ~/.local.  Unfortunately, the latter is already 
out in the field; that was a step in the wrong direction for OS X.
msg94637 - (view) Author: Ronald Oussoren (ronaldoussoren) Date: 2009-10-28 20:11
I agree with Ned that neither ~/.local nor /etc are a good fit for OSX, 
sadly enough I wasn't paying attention when ~/.local was added as python 
already had a per-user directory on OSX: ~/Library/Python.

The common unix directories are often not a good pick for good OSX 
citizens, even if OSX is build on Unix.

The OSX filesystem structure should be described somewhere below 
<http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/
BPFileSystem/BPFileSystem.html#//apple_ref/doc/uid/10000185>, although I 
haven't found a clear explanation yet.

Technically configuration files should be stored in /Library/Preferences 
(system wide) or ~/Library/Preferences (per user), but I'd say 
practicality beats purity here and I'd store configuration in 
/Library/Python/etc or ~/Library/Python/etc. 

BTW. I haven't read most of the discussion yet, I'll probably have more 
to add when I do.  What I did notice was a proposal to store the 
distutils cfg file in ~/.local/lib/pythonX.Y/site-
packages/distutils.cfg. IMHO that way to hidden and an unexpected 
location for storing configuration files.
msg94963 - (view) Author: Éric Araujo (Merwok) Date: 2009-11-06 03:10
When ~/.local/lib was chosen for the user directory, the BaseDir Spec
was given as prior example. Why not go the full way and follow the spec?
The config file could be $XDG_CONFIG_HOME/python/distutils, with
$XDG_CONFIG_HOME defaulting to ~/.config.

References:
http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
http://www.freedesktop.org/wiki/Software/pyxdg (deals with
freedesktop.org-approved file formats too; the part of the code that
deals with paths would make a useful addition to the stdlib, as more and
more applications follow the spec)
History
Date User Action Args
2009-11-06 03:10:43Merwoksetnosy: + Merwok
messages: + msg94963
2009-10-28 20:11:44ronaldoussorensetmessages: + msg94637
2009-10-28 19:19:52fwierzbickisetnosy: + fwierzbicki
2009-10-28 10:24:18ned.deilysetmessages: + msg94623
2009-10-28 09:46:17lemburgsetmessages: + msg94622
2009-10-28 09:40:49ned.deilysetnosy: + ronaldoussoren, ned.deily
messages: + msg94620
2009-10-26 22:36:38michael.foordsetmessages: + msg94531
2009-10-26 22:35:36michael.foordsetmessages: + msg94530
2009-10-26 22:28:33georg.brandlsetmessages: + msg94527
2009-10-26 22:12:44michael.foordsetmessages: + msg94523
2009-10-26 22:04:26tareksetnosy: + doko, michael.foord
messages: + msg94519
2009-10-26 21:06:56georg.brandlsetnosy: + georg.brandl
messages: + msg94507
2009-10-24 12:56:43tareksetmessages: + msg94412
2009-10-20 17:32:07lemburgsetmessages: + msg94293
2009-10-20 15:50:28tareksetnosy: + lemburg, barry
messages: + msg94289
2009-10-20 15:37:34pitrousetmessages: + msg94288
2009-10-20 15:21:10tareksetmessages: + msg94287
2009-10-20 15:17:10r.david.murraysetnosy: + r.david.murray
messages: + msg94285
2009-10-20 15:11:30pitrousetmessages: + msg94284
2009-10-20 15:03:36pitrousetmessages: + msg94282
2009-10-20 14:55:35tareksettype: feature request
messages: + msg94281
2009-10-20 14:39:51pitrousetnosy: + pitrou
messages: + msg94279
2009-10-20 11:21:15tarekcreate