This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bdist_rpm hardcodes setup.py as the script name
Type: Stage:
Components: Distutils Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: fer_perez, loewis, pearu
Priority: high Keywords:

Created on 2005-08-23 23:59 by fer_perez, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bdist_rpm.diff fer_perez, 2005-08-24 17:12 Patch
Messages (5)
msg26106 - (view) Author: Fernando Pérez (fer_perez) Date: 2005-08-23 23:59
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.
msg26107 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-24 05:41
Logged In: YES 
user_id=21627

Would you like to try your proposed fix yourself, and
contribute a patch?
msg26108 - (view) Author: Fernando Pérez (fer_perez) Date: 2005-08-24 17:12
Logged In: YES 
user_id=395388

Well, here's a patch against 2.4 (sorry, but I can't build
from CVS right now, I hope this is enough.

I tested it on my problem build linked above, and it now
works correctly, but I'm not a distutils expert, so I can't
vouch 100% that it won't break in some corner case.

It would be worth making sure that other similar commands
(like the new bdist_deb in CVS) don't share the problem.
msg26109 - (view) Author: Pearu Peterson (pearu) Date: 2006-01-28 09:18
Logged In: YES 
user_id=88489

Related bug is 828743.
In numpy.distutils we have long time used the same patch as
suggested by fer_perez without problems.
msg26110 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-07-03 12:30
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as r47213 and 47214 (for 2.4).
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42299
2005-08-23 23:59:07fer_perezcreate