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: Note that distutils’ bdist_rpm command is not used to build a CPython rpm
Type: Stage: resolved
Components: Distutils, Documentation Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Sean.Carolan, docs@python, eric.araujo, tarek
Priority: normal Keywords: easy

Created on 2013-03-26 20:28 by Sean.Carolan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg185298 - (view) Author: Sean Carolan (Sean.Carolan) Date: 2013-03-26 20:28
I'm attempting to build a Python 2.7.3 RPM but the build command from the documentation fails.  My platform is RHEL 5.9, x86_64

http://docs.python.org/2/distutils/builtdist.html#creating-rpm-packages

Steps to reproduce:

1.  Download latest Python tarball to home directory.
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

2.  Unpack it, configure and install it:
[scarolan@titania:~/Python-2.7.3]$ make clean; ./configure --with-zlib=/usr/include; make; sudo make install

3.  Attempt to run command in the documentation, build fails.

[scarolan@titania:~/Python-2.7.3]$ python -V
Python 2.7.3

[scarolan@titania:~/Python-2.7.3]$ python setup.py bdist_rpm
running bdist_rpm
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/rpm
creating build/bdist.linux-x86_64/rpm/SOURCES
creating build/bdist.linux-x86_64/rpm/SPECS
creating build/bdist.linux-x86_64/rpm/BUILD
creating build/bdist.linux-x86_64/rpm/RPMS
creating build/bdist.linux-x86_64/rpm/SRPMS
writing 'build/bdist.linux-x86_64/rpm/SPECS/Python.spec'
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

writing manifest file 'MANIFEST'
creating Python-2.7.3
creating Python-2.7.3/Lib
creating Python-2.7.3/Tools
creating Python-2.7.3/Tools/scripts
making hard links in Python-2.7.3...
hard linking README -> Python-2.7.3
'_struct.c' not a regular file -- skipping
hard linking setup.py -> Python-2.7.3
hard linking Lib/smtpd.py -> Python-2.7.3/Lib
hard linking Tools/scripts/2to3 -> Python-2.7.3/Tools/scripts
hard linking Tools/scripts/idle -> Python-2.7.3/Tools/scripts
hard linking Tools/scripts/pydoc -> Python-2.7.3/Tools/scripts
creating dist
Creating tar archive
removing 'Python-2.7.3' (and everything under it)
copying dist/Python-2.7.3.tar.gz -> build/bdist.linux-x86_64/rpm/SOURCES
building RPMs
rpmbuild -ba --define _topdir /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm --clean build/bdist.linux-x86_64/rpm/SPECS/Python.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.64365
+ umask 022
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ rm -rf Python-2.7.3
+ /bin/gzip -dc /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/SOURCES/Python-2.7.3.tar.gz
+ tar -xvvf -
drwxrwxr-x scarolan/scarolan 0 2013-03-26 15:26:01 Python-2.7.3/
-rw-rw-r-- scarolan/scarolan 1524 2013-03-26 15:26:01 Python-2.7.3/PKG-INFO
-rw-r--r-- scarolan/scarolan 90350 2012-04-09 18:07:36 Python-2.7.3/setup.py
-rw-r--r-- scarolan/scarolan 53744 2012-04-09 18:07:35 Python-2.7.3/README
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:26:01 Python-2.7.3/Tools/
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:26:01 Python-2.7.3/Tools/scripts/
-rwxr-xr-x scarolan/scarolan    79 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/pydoc
-rwxr-xr-x scarolan/scarolan    95 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/idle
-rwxr-xr-x scarolan/scarolan    96 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/2to3
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:26:01 Python-2.7.3/Lib/
-rwxr-xr-x scarolan/scarolan 18543 2012-04-09 18:07:31 Python-2.7.3/Lib/smtpd.py
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd Python-2.7.3
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.64365
+ umask 022
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ cd Python-2.7.3
+ env 'CFLAGS=-O2 -g -m64 -mtune=generic' python setup.py build
running build
running build_ext
error: pyconfig.h: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.64365 (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.64365 (%build)
error: command 'rpmbuild' failed with exit status 1


If I hard-code the location of pyconfig.h into setup.py, it still fails:

data = open('/home/scarolan/Python-2.7.3/pyconfig.h').read()

[scarolan@titania:~/Python-2.7.3]$ python setup.py bdist_rpm
running bdist_rpm
writing 'build/bdist.linux-x86_64/rpm/SPECS/Python.spec'
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

writing manifest file 'MANIFEST'
creating Python-2.7.3
creating Python-2.7.3/Lib
creating Python-2.7.3/Tools
creating Python-2.7.3/Tools/scripts
making hard links in Python-2.7.3...
hard linking README -> Python-2.7.3
'_struct.c' not a regular file -- skipping
hard linking setup.py -> Python-2.7.3
hard linking Lib/smtpd.py -> Python-2.7.3/Lib
hard linking Tools/scripts/2to3 -> Python-2.7.3/Tools/scripts
hard linking Tools/scripts/idle -> Python-2.7.3/Tools/scripts
hard linking Tools/scripts/pydoc -> Python-2.7.3/Tools/scripts
Creating tar archive
removing 'Python-2.7.3' (and everything under it)
copying dist/Python-2.7.3.tar.gz -> build/bdist.linux-x86_64/rpm/SOURCES
building RPMs
rpmbuild -ba --define _topdir /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm --clean build/bdist.linux-x86_64/rpm/SPECS/Python.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.43579
+ umask 022
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ rm -rf Python-2.7.3
+ /bin/gzip -dc /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/SOURCES/Python-2.7.3.tar.gz
+ tar -xvvf -
drwxrwxr-x scarolan/scarolan 0 2013-03-26 15:28:15 Python-2.7.3/
-rw-rw-r-- scarolan/scarolan 1524 2013-03-26 15:28:15 Python-2.7.3/PKG-INFO
-rw-r--r-- scarolan/scarolan 90378 2013-03-26 15:27:30 Python-2.7.3/setup.py
-rw-r--r-- scarolan/scarolan 53744 2012-04-09 18:07:35 Python-2.7.3/README
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:28:15 Python-2.7.3/Tools/
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:28:15 Python-2.7.3/Tools/scripts/
-rwxr-xr-x scarolan/scarolan    79 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/pydoc
-rwxr-xr-x scarolan/scarolan    95 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/idle
-rwxr-xr-x scarolan/scarolan    96 2012-04-09 18:07:35 Python-2.7.3/Tools/scripts/2to3
drwxrwxr-x scarolan/scarolan     0 2013-03-26 15:28:15 Python-2.7.3/Lib/
-rwxr-xr-x scarolan/scarolan 18543 2012-04-09 18:07:31 Python-2.7.3/Lib/smtpd.py
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd Python-2.7.3
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.43579
+ umask 022
+ cd /home/scarolan/Python-2.7.3/build/bdist.linux-x86_64/rpm/BUILD
+ cd Python-2.7.3
+ env 'CFLAGS=-O2 -g -m64 -mtune=generic' python setup.py build
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers
error: Modules/Setup: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.43579 (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.43579 (%build)
error: command 'rpmbuild' failed with exit status 1
msg185341 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-03-27 15:35
To build Python itself you need to use the Makefile and the Misc/RPM/python-2.7.spec file.  The doc you’re referring to talks about building rpm packages for Python libraries, not CPython itself.
msg185342 - (view) Author: Sean Carolan (Sean.Carolan) Date: 2013-03-27 15:37
Éric Araujo, if that is the case then why does it build what looks like a *.spec file for Python itself?

[scarolan@titania:~/Python-2.7.3]$ head -10 ./build/bdist.linux-x86_64/rpm/SPECS/Python.spec
%define name Python
%define version 2.7.3
%define unmangled_version 2.7.3
%define release 1

Summary: A high-level object-oriented programming language
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{name}-%{unmangled_version}.tar.gz
msg185343 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-03-27 15:48
Sorry, I don’t understand the question.

The point still stands: one should not use setup.py build_rpm to build an RPM for CPython.  Please read Misc/RPM/README.
msg185346 - (view) Author: Sean Carolan (Sean.Carolan) Date: 2013-03-27 16:05
Ok, thanks for clearing that up.  Maybe the documentation could be updated to explicitly state this to avoid confusion, eg:

"NOTE:  You cannot use setup.py to build a Python RPM.  It is only for building Python modules."
msg213483 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-13 22:18
On second thought, it seems to me that packagers already know that they should use their usual tool to create a CPython RPM, and I would not want to confuse Python developers with a note in the bdist_rpm doc.

If someone thinks there really should be a note in some README, please reopen the issue.
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61753
2014-03-13 22:18:12eric.araujosetstatus: open -> closed
resolution: rejected
messages: + msg213483

stage: needs patch -> resolved
2013-03-27 16:21:51eric.araujosetassignee: docs@python
title: python setup.py bdist_rpm is broken -> Note that distutils’ bdist_rpm command is not used to build a CPython rpm
components: + Distutils, Documentation, - Build

keywords: + easy
nosy: + tarek, docs@python
versions: + Python 3.2, Python 3.3, Python 3.4
stage: needs patch
2013-03-27 16:05:26Sean.Carolansetmessages: + msg185346
2013-03-27 15:48:47eric.araujosetmessages: + msg185343
2013-03-27 15:37:47Sean.Carolansetmessages: + msg185342
2013-03-27 15:35:19eric.araujosetnosy: + eric.araujo
messages: + msg185341
2013-03-26 20:28:37Sean.Carolancreate