[Distutils] distlib and data files => resources ?

PJ Eby pje at telecommunity.com
Mon Nov 19 20:26:38 CET 2012


On Sun, Nov 18, 2012 at 6:40 PM, Vinay Sajip <vinay_sajip at yahoo.co.uk>wrote:

> Chris McDonough <chrism <at> plope.com> writes:
>
> > >> That is not the definition of "resource" in setuptools-derived
> > >> systems.  The definition of resource in setuptools-derived systems is
> > >> "a non-Python file that lives in a package", which is exactly the
> > >> opposite of the above definition.  I'd suggest to avoid confusion we
> > >> don't call "files used by the project that must not be installed in
> > >> the same place that python modules or libraries", and we call this
> > >> other class of things something else.
>
> Perhaps confusingly, in the distlib documentation I've used "resource" to
> mean
> what you've said above, i.e. the setuptools definition. Whatever they're
> called, though, I think we shouldn't dictate that all non-Python files
> have to
> live in some other location than a package. Definitely, we need to
> consider the
> needs of distro packagers, but we should not force one particular way of
> working on all users.


Indeed.  The setuptools "resource" definition, btw, is intended to parallel
Java's and Windows'.  Java resources are not data, they are part of the
code.  Same thing for Windows resources.  In both cases, they are embedded
in executables (jars for java, exe's and dlls for windows).

Such resource files are not really "data", and flat out don't belong in
/etc, /var, /usr/share, or any other such locations, any more than icons in
a Java jar should be extracted and placed elsewhere.

The confusion that exists right now about data files stems from the fact
that distutils "data" files system really was originally intended for
*actual* data, that *should* be installed to non-library locations.
However, for people who needed resources, there was a widespread distutils
hack that abused the data_files key to install resources - a hack which
setuptools adopted, improved upon (as package_data), and was then adopted
back into distutils for Python 2.4.

If I'd realized this confusion would be happening several years later, I'd
have dubbed that key "package_resources", but at the time, it was the
logical-seeming name because of the already-widespread distutils hack.
(The resource_* APIs came later.)

I think we should use some clearly-distinct (and mutually exclusive)
terminology going forward:

* Data files: stuff the user can and/or should change, such as
configuration files, startup databases, etc.
* Resource files: constant files used at runtime, regardless of file type

Data files should never be installed to package directories.  But I'm not
aware of any good reason why resource files should ever be installed
anywhere *else*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20121119/8af910e8/attachment.html>


More information about the Distutils-SIG mailing list