[Distutils] I need to create a customized Fedora live cd with Python applications on it

Stanley A. Klein sklein at cpcug.org
Tue May 29 22:20:30 CEST 2007

On Tue, May 29, 2007 3:43 pm, Phillip J. Eby wrote:
> At 02:10 PM 5/29/2007 -0400, Stanley A. Klein wrote:
>>I found a report on bugzilla.redhat.com, "Bug 236535 Processed:
>>brp-python-bytecompile does not work with bdist-rpm target" and am
>> cc:'ing
>>the cc: list for that bug on this email.
>>I posted a comment to that bug strongly urging the Fedora packaging
>> people
>>and the Python packaging people to get their heads together and resolve
>>this issue.
>>For the benefit of the people on the Fedora bug cc: list, a posting to
>> the
>>Python distutils list that describes my problem can be found at
> Hi Stanley.  I reviewed the notes on the bug; this definitely
> explains why I haven't been able to reproduce your problem under
> CentOS (which is where I was testing it).
> It looks to me like there are two possible long-term fixes:
> 1. The Fedora folks could fix brp-python-bytecompile to automatically
> add the *.pyo files to the installed-files list (and adjust the
> compilation location) to remove the error(s).  (I think this is the
> best approach, as it ensures Fedora's policy is followed even for
> user-built RPMs.)
> 2. I could change setuptools to always generate *.pyo files when
> creating RPMs, or to have the option to do so -- and we'd also have
> to change the distutils in Python.
> The big problem with option #2 is that even if it were considered a
> bugfix for Python (which it *isn't*, since clearly the Fedora policy
> change is what's breaking it), it would have to wait until a Python
> 2.5.x release.  Is Fedora even *using* 2.5 yet?
> In the meantime, there is one workaround you can use with your
> distutils package.  Add the following two lines to 'setup.cfg' in the
> package root, adjacent to the 'setup.py' file:
> [install]
> optimize = 1
> This will force all RPM's built with the package to include *.pyo
> files, which should then dodge the
> (By the way, *.pyo files actually aren't all that useless.  More
> recent versions of Python actually do a few optimizations on the
> generated bytecode, including things like constant folding, in
> addition to removing "if __debug__:" blocks and "assert" statements.)

I used your workaround and got the rpms.  However, I also got a traceback,
attached below.  I think this is another problem in setuptools, because
(IIRC) I saw a posting relating to it.

I hope we are on the way to a general solution.  Fedora Core 5 (which I
currently run pending release of Fedora 7) distributes setuptools as a
separate package.  If Fedora 7 continues that policy, all that might be
needed is a new release of setuptools with an option (perhaps --Fedora)
that have the same effect as putting the two lines in the setup.cfg file. 
Alternatively, the Fedora distribution could put the lines into some kind
of global config file and setuptools could have an option (perhaps
--noFedora) to not use them.

Meanwhile, what is needed is to give much greater publicity to the


Stan Klein

(The traceback is at the bottom, but I've included more above to show that
the packaging seemed to work.)

Installing wsdl2dispatch script to /var/tmp/ZSI-2.0-1-buildroot/usr/bin
Installing wsdl2py script to /var/tmp/ZSI-2.0-1-buildroot/usr/bin
writing list of installed files to 'INSTALLED_FILES'
+ /usr/lib/rpm/find-debuginfo.sh
0 blocks
find: /var/tmp/ZSI-2.0-1-buildroot/usr/lib/debug: No such file or directory
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
Processing files: ZSI-2.0-1
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.59999
+ umask 022
+ cd /home/stan/exper/zsi2/ZSI-2.0/build/bdist.linux-i686/rpm/BUILD
+ cd ZSI-2.0
+ DOCDIR=/var/tmp/ZSI-2.0-1-buildroot/usr/share/doc/ZSI-2.0
+ export DOCDIR
+ rm -rf /var/tmp/ZSI-2.0-1-buildroot/usr/share/doc/ZSI-2.0
+ /bin/mkdir -p /var/tmp/ZSI-2.0-1-buildroot/usr/share/doc/ZSI-2.0
+ cp -pr README CHANGES doc/zsi.css doc/zsi.html
+ exit 0
warning: File listed twice:
warning: File listed twice:
warning: File listed twice:
warning: File listed twice:
warning: File listed twice:
warning: File listed twice:
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /usr/bin/python PyXML python(abi) = 2.4
Checking for unpackaged file(s): /usr/lib/rpm/check-files
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.49538
+ umask 022
+ cd /home/stan/exper/zsi2/ZSI-2.0/build/bdist.linux-i686/rpm/BUILD
+ cd ZSI-2.0
+ rm -rf /var/tmp/ZSI-2.0-1-buildroot
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.74009
+ umask 022
+ cd /home/stan/exper/zsi2/ZSI-2.0/build/bdist.linux-i686/rpm/BUILD
+ rm -rf ZSI-2.0
+ exit 0
moving build/bdist.linux-i686/rpm/SRPMS/ZSI-2.0-1.src.rpm -> dist
moving build/bdist.linux-i686/rpm/RPMS/noarch/ZSI-2.0-1.noarch.rpm -> dist
Traceback (most recent call last):
  File "setup.py", line 66, in ?
    long_description="For additional information, please see " + _url,
  File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
  File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
  File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
  File "/usr/lib/python2.4/site-packages/setuptools/command/bdist_rpm.py",
line 28, in run
  File "/usr/lib/python2.4/distutils/command/bdist_rpm.py", line 377, in run
    self.move_file(rpm, self.dist_dir)
  File "/usr/lib/python2.4/site-packages/setuptools/command/bdist_rpm.py",
line 20, in move_file
NameError: global name 'get_python_version' is not defined

More information about the Distutils-SIG mailing list