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 should use rpmbuild, not rpm
Type: Stage: resolved
Components: Distutils Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: James.Bennet, bhyde, cheryl.sabella, cstratak, eric.araujo, eric.smith, miss-islington, ned.deily, petere, purpleidea, stanp, tarek, westley.martinez
Priority: normal Keywords: easy, patch

Created on 2011-02-04 21:19 by purpleidea, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix-rpm-use-2.7.diff eric.araujo, 2014-03-13 22:22
Pull Requests
URL Status Linked Edit
PR 10594 merged n0npax, 2018-11-18 20:10
PR 13922 merged miss-islington, 2019-06-08 21:07
Messages (25)
msg127942 - (view) Author: James (purpleidea) Date: 2011-02-04 21:19
Hi distutils,

When I run:

./setup.py bdist --formats=rpm

on my source directory, I get the error:

rpm -ba --define _topdir /home/james/code/scantran/build/bdist.linux-x86_64/rpm --clean build/bdist.linux-x86_64/rpm/SPECS/scantran.spec
-ba: unknown option
error: command 'rpm' failed with exit status 1

It seems the problem can be fixed by installing the rpm-build package (on fedora 14 anyways) and so perhaps something should be done so that this is more obvious...

HTH,
James
msg127943 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-04 21:23
Does this mean that there is one rpm command that does not have all options, and that rpm-build overwrites that command with another one that does the right thing?
msg127944 - (view) Author: James (purpleidea) Date: 2011-02-04 21:32
In the source for distutils it seems to attempt to use 'rpmbuild' if it exists, but otherwise falls back on regular 'rpm', however in my rpm:

$ rpm --version
RPM version 4.8.1

this fails as there is no -ba option.

James
msg127945 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-04 21:37
What is your OS name and version?  Is that rpm version considered obsolete or not?
msg127948 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-02-04 22:45
"rpm -ba" is very old. I think it's been at least since 2002 that "-ba" was supported by rpm.

I believe bdist_rpm is calling "rpmbuild -ba", and if that doesn't exist, then "rpm -ba" is a transition strategy until all systems supported "rpmbuild". This transition period should be over. Unfortunately today it's far more likely that "rpm -ba" will not be what you want to call, but "rpm" will almost always be found, giving this error.

Most systems (certain RedHat based) ship rpmbuild as a separate command. RedHat installs it via the rpm-build package.

I'd suggest just switching bdist_rpm to always use rpmbuild. Then at least the error would be that rpmbuild isn't found.
msg127958 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-05 01:01
This is a gray area between bugfix and bahavior change forbidden by the feature freeze.  Would it be okay for you to add a note in the docs and close this report?
msg127959 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-05 01:02
> Would it be okay for you to add a note in the docs and close this report?

I meant to ask whether you would agree with that outcome, not that you should do the work (you’re welcome to provide a patch if you want to, but that’s not required).
msg128005 - (view) Author: James (purpleidea) Date: 2011-02-05 17:41
I'll write a docs and script patch for this next week...

I'm happy to do the work,

Thanks for the comments.

James
msg128052 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-06 12:02
Thanks for volunteering.  I will review and apply when the py3k branch is unfrozen.

> I'll write a docs and script patch for this next week...
Note that I proposed to patch the docs only.
msg128053 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-06 12:05
BTW, it may be useful to point people to http://pypi.python.org/pypi/pypi2rpm, which contains an updated command, bdist_rpm2.
msg153098 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-11 05:25
Given that we’ve made changes to distutils for Debian multiarch or Mac OS X compiler breakage, I now think that switching distutils to only use rpmbuild would be reasonable.
msg155120 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-07 20:54
More info on rpm vs. rpmbuild: http://bugs.python.org/issue1533164#msg82592
msg175042 - (view) Author: Peter Eisentraut (petere) * Date: 2012-11-07 04:50
I ran into a similar instance of this problem today and would like to add my support for just getting rid of the "rpm" calls and just call "rpmbuild" in all cases.  The last release where "rpm" was used for building was more than 10 years ago.
msg177241 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-12-09 22:02
I agree on just switching to rpmbuild, at least for 3.4.
msg193105 - (view) Author: James Bennet (James.Bennet) Date: 2013-07-15 14:28
I have observed this bug under CentOS 5.9 using the version of python-setuptools from the official CentOS repository. -ba is not a valid option for that version of RPM. I am able to get further by installing the rpm-build package.
msg213484 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-13 22:22
Can someone test the attached patch for 2.7?  I don’t know if the second use (rpm -q --qf etc) should be converted too.
msg213588 - (view) Author: Peter Eisentraut (petere) * Date: 2014-03-14 20:15
No, the second use should not be converted.
msg315180 - (view) Author: Stanislav P (stanp) Date: 2018-04-10 21:03
can this patch be sped up?
i am running into this issue with the latest python version
the patch was submitted 7 years ago

i don't see any workaround.
msg315188 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2018-04-11 09:55
I could make a PR out of the patch but I wonder if anyone is actually using this functionality. Wearing my Fedora's python maintainer hat, we have a lot of tooling around rpm that handles those things, so I don't think there is a valid usecase for Fedora at least. Is it useful somehow for other rpm based distros or is the resulting rpm's functional enough for some testing at least?
msg315197 - (view) Author: Stanislav P (stanp) Date: 2018-04-11 17:30
i am using this on redhat enterprise  and mac. both running python 3.5
both running latest rpm. if you can make a pr it would great.
msg315198 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2018-04-11 17:34
The bug exists indeed but I would like to know what is the actual use case here.
msg315200 - (view) Author: Stanislav P (stanp) Date: 2018-04-11 20:20
the use case is being able to publish python package as rpm using setup.py on mac.
msg330061 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-11-18 19:29
Note that Issue32281 also describes the problem of trying to use build_rpm on non-rpm systems, again specifically macOS.  Before stumbling on this issue,I had suggested over there to use change bdist_rpm to not use hardwired paths for rpmbuild but, if the better solution is to just unconditionally use rpmbuild, let's do that instead.
msg345063 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-06-08 21:05
New changeset 45a14942c969ed508b35abd5e116cb18f84ce5b4 by Cheryl Sabella (Marcin Niemira) in branch 'master':
bpo-11122: fix hardcoded path checking for rpmbuild in bdist_rpm.py (GH-10594)
https://github.com/python/cpython/commit/45a14942c969ed508b35abd5e116cb18f84ce5b4
msg345067 - (view) Author: miss-islington (miss-islington) Date: 2019-06-08 21:25
New changeset 3f7629d93c8cb3e0ee118c6a6463250f03d6c9f9 by Miss Islington (bot) in branch '3.8':
bpo-11122: fix hardcoded path checking for rpmbuild in bdist_rpm.py (GH-10594)
https://github.com/python/cpython/commit/3f7629d93c8cb3e0ee118c6a6463250f03d6c9f9
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55331
2019-06-08 21:25:24miss-islingtonsetnosy: + miss-islington
messages: + msg345067
2019-06-08 21:07:15miss-islingtonsetpull_requests: + pull_request13795
2019-06-08 21:06:22cheryl.sabellasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-08 21:05:09cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg345063
2018-11-18 20:10:22n0npaxsetpull_requests: + pull_request9839
2018-11-18 19:29:02ned.deilysetmessages: + msg330061
2018-11-18 19:25:44ned.deilylinkissue32281 superseder
2018-11-18 19:25:33ned.deilysetnosy: + ned.deily, bhyde

versions: - Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6
2018-04-11 20:20:01stanpsetmessages: + msg315200
2018-04-11 17:34:56cstrataksetmessages: + msg315198
2018-04-11 17:30:10stanpsetmessages: + msg315197
2018-04-11 09:55:08cstrataksetnosy: + cstratak
messages: + msg315188
2018-04-10 21:03:12stanpsetnosy: + stanp

messages: + msg315180
versions: + Python 3.5, Python 3.6, Python 3.7, Python 3.8
2014-03-14 20:15:50peteresetmessages: + msg213588
2014-03-13 22:22:17eric.araujosetfiles: + fix-rpm-use-2.7.diff
versions: + Python 3.4, - Python 3.2
messages: + msg213484

keywords: + patch
stage: needs patch -> patch review
2014-02-26 20:37:32westley.martinezsetnosy: + westley.martinez
2013-07-15 14:28:44James.Bennetsetnosy: + James.Bennet
messages: + msg193105
2012-12-09 22:02:45eric.smithsetmessages: + msg177241
2012-11-07 04:50:19peteresetnosy: + petere
messages: + msg175042
2012-03-07 20:55:03eric.araujosettitle: bdist_rpm fails -> bdist_rpm should use rpmbuild, not rpm
2012-03-07 20:54:46eric.araujosetkeywords: + easy

messages: + msg155120
stage: needs patch
2012-02-11 05:25:58eric.araujosetmessages: + msg153098
versions: - Python 3.1
2011-02-06 12:05:29eric.araujosetnosy: eric.smith, tarek, eric.araujo, purpleidea
messages: + msg128053
2011-02-06 12:02:01eric.araujosetassignee: tarek -> eric.araujo
messages: + msg128052
nosy: eric.smith, tarek, eric.araujo, purpleidea
2011-02-05 17:41:12purpleideasetnosy: eric.smith, tarek, eric.araujo, purpleidea
messages: + msg128005
2011-02-05 01:02:30eric.araujosetnosy: eric.smith, tarek, eric.araujo, purpleidea
messages: + msg127959
2011-02-05 01:01:18eric.araujosetnosy: eric.smith, tarek, eric.araujo, purpleidea
messages: + msg127958
versions: + Python 3.1, Python 3.2, Python 3.3
2011-02-04 22:45:24eric.smithsetnosy: + eric.smith
messages: + msg127948
2011-02-04 21:37:33eric.araujosetnosy: tarek, eric.araujo, purpleidea
messages: + msg127945
2011-02-04 21:32:13purpleideasetnosy: tarek, eric.araujo, purpleidea
messages: + msg127944
2011-02-04 21:23:41eric.araujosetnosy: tarek, eric.araujo, purpleidea
messages: + msg127943
2011-02-04 21:19:22purpleideacreate