from distutils.core import setup setup(name='foo', version='1.0', py_modules=['foo'])
[2, docs.python.org/distutils/introduction#a-simple-example]
python setup.py sdist # create a source distribution python setup.py test # run unittest suite python setup.py install # installation at system
setup.py?Defines the current directory as root of a python distribution. Contains metadata and a description for relation of files to be distributed.
from setuptools import setup (stable)from distutils.core import setup [python <3.3] (use nowadays)from distutils2 import … [python >=2.4] (future)
Distutils is the standard tool used for packaging. It works rather well for simple needs, but is limited and not trivial to extend.
—Éric Araujo (distutils maintainer) [3, stackoverflow.com]
easy_install <module> # apt-get install python-setuptools
Deprecated.
pip install <module> # apt-get install python-pip
Use it! (As of 2012-10-05)
bereite drei [vorträge] vor, und je nachdem welches tool diese sekunde dann grad nicht obsolet ist, nimmst du den passenden
— weasel on IRC
If a package requires the setuptools package, it is our recommendation that you install the Distribute package, which provides a more up to date version of setuptools than does the original Setuptools package.
python-setuptools is provided via 'distribute', starting with Debian/wheezy distribute is part of python-setuptools package; the python-setuptools package is built from distribute sources
dh_python2 - calculates Python dependencies, adds maintainer scripts to byte compile files, etc.
% man dh_python2 dh_python3
cat > debian/rules << EOF
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
%:
dh $@ --with python2
EOF
% cat > debian/control << EOF
Source: python-foobar
Section: python
Priority: extra
Maintainer: Your Name <mail@example.org>
Build-Depends: debhelper (>= 7),
python-all
Standards-Version: 3.9.4
Package: python-foobar
Architecture: all
Depends: [...]
${misc:Depends},
${python:Depends}
Description: short description
longer package description...
EOF
PS: use python-all-dev in Build-Depends when building extensions
As usual (AKA as in other Debian packages)
% gem2deb chef % dh-make-perl --source-format "3.0 (quilt)" --dh 8 --cpan XML::Entities
py2dsc exists but sadly is too unreliable (because you can't rely on setup.py), BUT:
tool for automatic conversion of PyPI repository to (unofficial) Debian repository
% lintian -IE $package_*.changes % lintian-info -t $PROBLEM