[Distutils] How can I get setuptools to include files beyond what find_packages() finds?

Stanley A. Klein sklein at cpcug.org
Tue Jul 31 21:34:23 CEST 2007

Robert Kern wrote:
Stanley A. Klein wrote:

>> Robert -
>> Thanks for illuminating the issue.
>> The problem I had was as follows.  Fedora (also RedHat) uses SE-Linux,
which needs to know all the files expected to be in sensitive
>> such as the Python site-packages.  This includes the pyc and pyo files
ordinarily generated by Python as the .py files are executed.
>> It turns out that to do a bdist_rpm for Fedora, it is necessary to
>> a setup.cfg file containing the lines:
>> [install]
>> optimize = 1
>> or to add these lines to the existing setup.cfg file.
>> If that is not done, the result in Fedora is an unpackaged files error.

>> This is due to the fact that if distutils/setuptools doesn't cause the
>> and pyo files to be created, Fedora will create them but they won't be
properly handled in the spec file created by distutils/setuptools.
>> In trying to do bdist_rpm with kiva, I got the unpackaged files error. 
This implies that numpy distutils did not properly handle the
>> in the setup.cfg (when I did "python setup.py bdist_rpm").  That's when
>> went to the workaround that resulted in this thread.
>> I hope this clarifies the problem.

>Not quite. I don't know what "the unpackaged files error" looks like. Can
>try Phillip's suggestion using --root and --record and show us the
results? Did
>you run "python setup.py build" before "python setup.py bdist_rpm"? We've
>seen problems with the dependency-handling between distutils commands.

I tried your second suggestion and it didn't work.  Running bdist_rpm
starts the whole process from scratch.

Regarding Phillip's suggestion, when running bdist_rpm I don't have direct
access to --root and --record.  However, in trying to track it down, I
think I may have found something that is contributing to the problem.

When running bdist_rpm, the install command options appear to be set in a
script located in the %install part of the rpm spec file.  Most
likely, the install is called by the rpm program and is controlled by the
spec file.  The install script in the kiva spec file is "python setup.py
install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES".  The install
scripts in the other spec files (that worked) are "python
setup.py install --single-version-externally-managed --root=

I looked at the numpy distutils.  In many cases they check to see if
setuptools is installed, and if so they import the relevant setuptools
modules (otherwise they import the distutils modules).  In particular, the
install command does that.  However, in the numpy distutils, the bdist_rpm
command does not.  It only uses the distutils bdist_rpm, that produces the
spec file install script shown above.  It seems to me that the setuptools
install is being called via the numpy distutils without the
--single-version-externally-managed option it would expect if its own
bdist_rpm were being used to build the spec file.

I don't know if that is enough to get the install to ignore including the
pyc and pyo files in the INSTALLED_FILES as essentially specified in the
setup.cfg option, but it is clearly a glitch that could cause
unexpected behavior.

The issue with the .so files arose because of my effort to work around the
issue of the pyc and pyo files.  I think the proper choice of
bdist_rpm to import may be closer to the cause of the original problem.

I tried to do something to fix the numpy distutils bdist_rpm.py (by trying
to follow what was done in install.py) but it didn't work and I got an
error message I didn't understand.

Stan Klein

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/distutils-sig/attachments/20070731/e6fe2c46/attachment.html 

More information about the Distutils-SIG mailing list