[Python-Dev] "setuptools has divided the Python community"

Guido van Rossum guido at python.org
Thu Mar 26 17:41:15 CET 2009


On Wed, Mar 25, 2009 at 9:40 PM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:
> I think Distutils (and therefore Setuptools) should provide some APIs
> to play with special files (like resources) and to mark them as being special,
> no matter where they end up in the target system.
>
> So the code inside the package can use these files seamessly no matter
> what the system is
> and no matter where the files have been placed by the packager.
>
> This has been discussed already but not clearly defined.

Yes, this should be done. PEP 302 has some hooks but they are optional
and not available for the default case. A simple wrapper to access a
resource file relative to a given module or package would be easy to
add. It should probably support four APIs:

- Open as a binary stream
- Open as a text stream
- Get contents as a binary string
- Get contents as a text string

(I am proposing these somewhat redundant APIs since for some loader
implementations the stream APIs are "natural" and the string APIs
should be built on top of that, while for other loaders the string
APIs are natural and the stream APIs would have to wrap a StringIO
instance around this. Providing all four APIs means that the
application can use the API that is most natural for *it*, which
avoids double wrapping.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list