[ python-Bugs-1267547 ] bdist_rpm hardcodes setup.py as the script name

SourceForge.net noreply at sourceforge.net
Wed Aug 24 07:41:03 CEST 2005


Bugs item #1267547, was opened at 2005-08-24 01:59
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1267547&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Fernando Pérez (fer_perez)
Assigned to: Nobody/Anonymous (nobody)
Summary: bdist_rpm hardcodes setup.py as the script name

Initial Comment:
The bdist_rpm command hardcodes 'setup.py' as the name of the setup script in the .spec file it generates.  A grep of the bdist_rpm file shows this:

planck[command]> grep -n -C 3 setup.py bdist_rpm.py
454-
455-        # rpm scripts
456-        # figure out default build script
457:        def_build = "%s setup.py build" % self.python
458-        if self.use_rpm_opt_flags:
459-            def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
460-
--
468-            ('prep', 'prep_script', "%setup"),
469-            ('build', 'build_script', def_build),
470-            ('install', 'install_script',
471:             ("%s setup.py install "
472-              "--root=$RPM_BUILD_ROOT "
473-              "--record=INSTALLED_FILES") % self.python),
474-            ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),

But there are packages out there which ship with multiple setup files, named setup-foo.py, setup-bar.py, etc.  While distutils correctly copies over the proper setup-X.py file to the build/ directory, the bdist_rpm command fails because rpm then tries to issue a build command against 'setup.py', which doesn't exist.  An example can be seen by downloading the clnum library from http://calcrpnpy.sourceforge.net/clnum.html, and trying:

lanck[rpncalc-2.0]> python clnum_setup.py bdist_rpm
running bdist_rpm
creating build
creating build/bdist.linux-i686
creating build/bdist.linux-i686/rpm
creating build/bdist.linux-i686/rpm/SOURCES
creating build/bdist.linux-i686/rpm/SPECS
creating build/bdist.linux-i686/rpm/BUILD
creating build/bdist.linux-i686/rpm/RPMS
creating build/bdist.linux-i686/rpm/SRPMS
writing 'build/bdist.linux-i686/rpm/SPECS/clnum.spec'
running sdist
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)
warning: sdist: standard file not found: should have one of README, README.txt
writing manifest file 'MANIFEST'
creating clnum-1.0
creating clnum-1.0/clnum
creating clnum-1.0/clnum/src
creating clnum-1.0/test
making hard links in clnum-1.0...
hard linking clnum_setup.py -> clnum-1.0
hard linking clnum/__init__.py -> clnum-1.0/clnum
hard linking clnum/_clnum_str.py -> clnum-1.0/clnum
hard linking clnum/src/clnum.cpp -> clnum-1.0/clnum/src
hard linking test/test_clnum.py -> clnum-1.0/test

[... snip]

Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.8191
+ umask 022
+ cd /usr/local/installers/src/rpncalc-2.0/build/bdist.linux-i686/rpm/BUILD
+ cd clnum-1.0
+ LANG=C
+ export LANG
+ unset DISPLAY
+ env 'CFLAGS=-O2 -g -pipe -m32 -march=i386 -mtune=pentium4' python setup.py build
python: can't open file 'setup.py'
error: Bad exit status from /var/tmp/rpm-tmp.8191 (%build)

I think that the fix is as simple as replacing the hardcoded 'setup.py' name by os.path.basename(sys.argv[0]), but I'm not 100% sure.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-08-24 07:41

Message:
Logged In: YES 
user_id=21627

Would you like to try your proposed fix yourself, and
contribute a patch?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1267547&group_id=5470


More information about the Python-bugs-list mailing list