[Distutils] [setuptools] When .py files are "data", strange things happen
David Handy
david at handysoftware.com
Thu Jan 5 04:54:05 CET 2006
I want setuptools to install a bunch of sample scripts in a package-relative
directory. Each end user will later run a script that copies these to a
directory relative to his or her home directory.
However, strange things happen to data files that have a .py extension.
1) Saying "include_package_data = True" was not enough to get them included
in the egg. The .txt files were included, but the .py files were
magically excluded.
2) I overcame the above problem with the following setup parameter:
package_data = {
# Include all .py files in the data directories, they
# are excluded by default.
'cpif.data': ['lander/*.py', 'samples/*.py'],
}
But now I get a bogus .pyc file generated for each of these sample
scripts. These bogus .pyc files get included in the egg.
3) I tried to overcome problem #2 above with the following setup parameter:
exclude_package_data = {
# The example programs should not be shipped with .pyc files
# XXX This is not working, the .pyc files are being created and
# included anyway.
'cpif.data': ['lander/*.pyc', 'samples/*.pyc'],
}
But this didn't work. Putting the following lines in my MANIFEST.in file
also didn't work:
exclude cpif/data/lander/*.pyc
exclude cpif/data/samples/*.pyc
I suppose I could turn off .pyc file generation, but that's not what I want.
I just want to treat certain .py files as data files. The "data" .py files
are in a subdirectory of a python package, but the directory in which they
directly reside does not contain an __init__.py file, so they are not
directly importable. So I don't think .pyc files should be generated for
them in any case.
Thanks in advance for ideas/sympathy/fixes, etc.
--
David Handy
Computer Programming is Fun!
Beginning Computer Programming with Python
http://www.handysoftware.com/cpif/
More information about the Distutils-SIG
mailing list