[Python-Dev] PEP 427: data directory

Paul Moore p.f.moore at gmail.com
Tue Oct 23 09:04:38 CEST 2012


On 22 October 2012 21:35, Daniel Holth <dholth at gmail.com> wrote:
> On Mon, Oct 22, 2012 at 4:26 PM, Daniel Holth <dholth at gmail.com> wrote:
>> On Mon, Oct 22, 2012 at 4:20 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>>>
>>> Hello,
>>>
>>> The FAQ has this weird statement:
>>>
>>> “This specification does not have an opinion on how you should organize
>>> your code. The .data directory is just a place for any files that are
>>> not normally installed inside site-packages or on the PYTHONPATH.”
>
> I mean to say that just because there is a .data/ directory it doesn't
> mean you have to stop using pkgutil.get_data(package, resource). Some
> people will take those 4 letters "data" to mean that any file that
> doesn't start with .py has to go there instead of in the root of the
> archive.

It might be worth being very explicit in the PEP that the wheel format
is based specifically on the distutils/sysconfig categories for file
locations (purelib, platlib, data, scripts, ...). If a setup.py is
written with custom code to install scripts in locations not
controlled by the various --install-XXX flags to distutils, it is
undefined how to package the non-standard files in the wheel format.
This is the same behaviour as for the wininst format (certainly, I've
checked the code :-)) and the egg format (I think, but I didn't check
the code for this).

Antoine's example of /etc/init.d is *not* custom code, it is standard
distutils (although not very well documented :-() What setup.py
install does is to make the given path relative to the data directory
which is sys.prefix on Windows, and appears to be similar on Posix
(the value of sysconfig.get_path('data') should give it, but I don't
have a Linux box handy to try it on). I don't see any obvious
documentation confirming that it does what I assume Antoine actually
wants, which is to put the file in /etc/init.d (which would of course
make the package non-relocatable, and hence mean that it would break
isolation in a virtualenv).

Apologies if this is obvious to everyone, but I suspect it should be
stated explicitly in the PEP, if only to avoid confusion. Something
like the following:

"""
The contents of a wheel file consist of:

1. The root of the wheel, which is all files to be installed in
"purelib" (or "platlib" if there is no purelib)
2. The dist-info directory, containing metadata
3. The data directory, which contains one subdirectory for each
sysconfig scheme not already covered (i.e., data, scripts, include,
and possibly platlib)

How files which would be installed to locations not defined by a
sysconfig path are stored in a wheel is not defined by this version of
the spec.

This layout offers all of the functionality of the existing wininst
and egg binary formats.
"""

Paul


More information about the Python-Dev mailing list