[Distutils] First attempt: close but no data files!
P.J. Eby
pje at telecommunity.com
Fri Oct 23 04:37:48 CEST 2009
At 06:26 PM 10/22/2009 -0700, Kaelin Colclasure wrote:
>On Oct 22, 2009, at 6:14 PM, P.J. Eby wrote:
>
>>At 05:47 PM 10/22/2009 -0700, Kaelin Colclasure wrote:
>>>Greetings,
>>>
>>>I am attempting my first Python contribution and have run into a
>>>speed
>>>bump getting a working setup.py using setuptools. Specifically, I
>>>cannot coax it to install my package data files into the site- packages
>>>directory. Here is a link to my project where my setup.py is
>>>available
>>>for browsing:
>>>
>>><http://bitbucket.org/kaelin/cuttlefish/>
>>
>>There's no setup.py there.
>
>
>Oops, forgot to `hg push`... It's there now. :-)
Your "package data" isn't being included because you don't have any
packages, only a module.
Move your cuttlefish.py to cuttlefish/__init__.py, and put the .plist
file in the same directory with it, and switch from py_modules to
packages in your setup() arguments. That will make it get included
with your installs and eggs.
Finally, you may want to drop use of __file__ and use the
pkg_resources API to access your data files instead, so that your
library will work when it's installed as a zipfile:
http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access
For example, rather than using __file__ to find the .plist file, you might use:
contents = resource_string(__name__, 'cuttlefish-config.plist')
to load the contents of the file as a string.
(This step is optional; if you use __file__ in your code, setuptools
will mark your project's eggs as requiring unzipping, and they will
be installed unzipped. So, you don't *have to* do it, the __file__
use will still work.)
More information about the Distutils-SIG
mailing list