[Distutils] pre-release versioning problems with sdist, bdist_rpm, bdist_debian

Gerry Reno greno at verizon.net
Fri Jan 9 02:12:19 CET 2009

When I create a set of distro packages for a specific distro, I need to 
distribute both a tarball and a distro-specific package such as an RPM 
or a deb archive.  Some people like installing things from tarballs, 
others like using the distro package manager.  So I let them have it 
both ways.  We can generate the tarball using 'sdist' and generate the 
distro-package with 'bdist_rpm', etc.

This all works great as long as we're talking final releases here: 
4.9.0, 5.0.0.   But, whenever you start to introduce pre-release 
candidate versioning, eg: 5.0.0_rc2, then things unravel.

What I have been attempting to do, and is apparently is like trying to 
find the holy grail, is to be able to generate both tarballs and 
distro-packages for both pre-release candidates and final releases, that 
exhibit the following behavior:

tarballs:                        foo-5.0.0_rc1.tar.gz       
(version=5.0.0_rc1); (extracts a foo-5.0.0_rc1 directory;  'sdist' 
requires version set like this so tarball name is unique and extract dir 
is unique)
distro-package (pre-release):    foo-5.0.0-0_rc1.noarch.rpm 
(version=5.0.0 and release=0_rc1)
distro-package (final release):  foo-5.0.0-1.noarch.rpm     
(version=5.0.0 and release=1);  'bdist_rpm' requires version and release 
set like this so final release will update the pre-release candidate package

The problem is that there appears to be no way to get a coordinated 
behavior between 'sdist' and 'bdist_rpm' as far as version and release 
strings are concerned that will satisfy both tarballs and bdist packages.
'sdist' knows nothing about 'release' string so you are forced to put 
the pre-release candidate information into the 'version' string' but as 
soon as you do that then you break 'bdist' packaging.  And to complicate 
matters, the world seems to have settled for making pre-release 
candidate version strings like '5.0.0_rc1' for many applications.

For example:

We have an application, foo-5.0.0, and we want to put out some 
pre-release candidates for testing, so we set the version to "5.0.0_rc1" 
in setup.py.

We create the source distribution with:
$ python setup.py sdist
which creates a source archive, foo-5.0.0_rc1.tar.gz.

We extract this archive and 'cd' into the foo-5.0.0_rc1 directory and 
create a built distribution with:
$ python setup.py bdist_rpm
which creates source and binary RPMS in the form:  

So we think everything is fine.  Everyone installs and tests using the 
pre-release candidate and subsequent candidates but when you eventually 
get to the final release, foo-5.0.0, and build your final release RPMS, 
foo-5.0.0-1.noarch.rpm, you find that it will not update your last 
pre-release candidate RPM, foo-5.0.0_rcX-1.noarch.rpm because it is not 
"rpm newer".

I'm hoping there is some distutils guru that can tell me how to solve 
this enigma or show me how to extend distutils to accomplish what is needed.


PS: In case anyone notices, yes, I posted a similar question yesterday 
on the python list without much response, but the question really 
belongs on this list.

More information about the Distutils-SIG mailing list