Not Logged In

stdeb 0.5.1

stdeb produces Debian source
packages from Python packages via a new distutils command,
sdist_dsc. Automatic defaults are provided for the Debian package,
but many aspects of the resulting package can be customized (see the
customizing section, below). An additional command, bdist_deb,
creates a Debian binary package, a .deb file.

Two convenience utilities are also provided. pypi-install will
query the Python Package Index (PyPI) for
a package, download it, create a .deb from it, and then install the
.deb. py2dsc will convert a distutils-built source tarball into a
Debian source package.

Distutils command packages can also be specified in distutils
configuration files (rather than using the --command-packages
command line argument to setup.py), as specified in the distutils
documentation. Specifically, you
could include this in your ~/.pydistutils.cfg file:

Warning: Despite doing its best, there is absolutely no way stdeb
can guarantee all the Debian package dependencies will be properly
fulfilled without manual intervention. Using pypi-install bypasses
your ability to customize stdeb’s behavior. Read the rest of this
document to understand how to make better packages.

This will make a Debian source package (.dsc, .orig.tar.gz and
.diff.gz files) and then compile it to a Debian binary package (.deb)
for your current system. The result will be in deb_dist.

Warning: installing the .deb file on other versions of Ubuntu or
Debian than the one on which it was compiled will result in undefined
behavior. If you have extension modules, they will probably
break. Even in the absence of extension modules, bad stuff will likely
happen.

For this reason, it is much better to build the Debian source package
and then compile that (e.g. using Ubuntu’s PPA) for each target
version of Debian or Ubuntu.

This example is more useful if you don’t have a Python source package
(.tar.gz file generated by python setup.py sdist). For the sake of
illustration, we do download such a tarball, but immediately unpack it
(alternatively, use a version control system to grab the unpacked
source of a package):

For the average Python package, its source distribution
(python_package.tar.gz created with python setup.py sdist)
contains nearly everything necessary to make a Debian source
package. This near-equivalence encouraged me to write this distutils
extension, which executes the setup.py file to extract relevant
information. setuptools may optionally
be used.

I wrote this initially to Debianize several Python packages of my own,
but I have the feeling it could be generally useful. It appears
similar, at least in theory, to easydeb, Logilab’s Devtools,
bdist_dpkg and bdist_deb.

This creates a Debian package with the Debian version set to
“0MyName1”.

These options can also be set via distutils configuration
files. (These are the setup.cfg file alongside setup.py and
the ~/.pydistutils.cfg file.) In that case, put the arguments in the
[sdist_dsc] section. For example, a project’s ~/.setup.cfg
file might have this:

[sdist_dsc]
force-buildsystem: False

To pass these commands to sdist_dsc when calling bdist_deb, do this:

python setup.py sdist_dsc --debian-version 0MyName1 bdist_deb

Command line option

Effect

–dist-dir (-d)

directory to put final built
distributions in (default=’deb_dist’)

–patch-already-applied (-a)

patch was already applied (used when
py2dsc calls sdist_dsc)

–extra-cfg-file (-x)

additional .cfg file (in addition to
.egg-info/stdeb.cfg if present)

–patch-file (-p)

patch file applied before setup.py
called (incompatible with file
specified in .cfg)

–patch-level (-l)

patch file applied before setup.py
called (incompatible with file
specified in .cfg)

–patch-posix (-q)

apply the patch with –posix mode

–remove-expanded-source-dir (-r)

remove the expanded source directory
requires.txt in the egg-info directory

–pycentral-backwards-compatibility

If True (currently the default), enable
migration from old stdeb that used
pycentral

–workaround-548392

If True (currently the default), limit
binary package to single Python
version, working around Debian bug
548392 of debhelper

–force-buildsystem

If True (the default), set ‘DH_OPTIONS=
–buildsystem=python_distutils’

–no-backwards-compatibility

If True, set –pycentral-backwards-
compatibility=False and –workaround-
548392=False. (Default=False).

–guess-conflicts-provides-replaces

If True, attempt to guess
Conflicts/Provides/Replaces in
debian/control based on apt-cache
output. (Default=False).

–use-premade-distfile (-P)

use .zip or .tar.gz file already made
by sdist command

You may also pass any arguments described below for the stdeb.cfg file
via distutils options. Passing the arguments this way (either on the
command line, or in the [sdist_dsc] section of a distutils .cfg
file) will take precedence. The option name should be given in lower
case.

You may write config files of the format understood by ConfigParser. When building
each package, stdeb looks for the existance of a stdeb.cfg in the
directory with setup.py. You may specify an additional config file
with the command-line option –extra-cfg-file. The section should
should either be [DEFAULT] or [package_name], which package_name is
specified as the name argument to the setup() command. An example
stdeb.cfg file is:

I don’t have a lot of time for this. This project stands a very real
chance of being only a shadow of its potential self unless people step
up and contribute. There are numerous ways in which people could
help. In particular, I’d be interested in finding a co-maintainer or
maintainer if the project generates any interest. Secondarily, I would
appreciate advice from Debian developers or Ubuntu MOTUs about the
arcane details of Python packaging.