How to use Python distutils? How to use Python distutils? python python

How to use Python distutils?


See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same.

Here is a real-life (anonymized) example:

#!/usr/bin/python from distutils.core import setup setup (name = 'Initech Package 3',           description = "Services and libraries ABC, DEF",           author = "That Guy, Initech Ltd",           author_email = "that.guy@initech.com",           version = '1.0.5',           package_dir = {'Package3' : 'site-packages/Package3'},           packages = ['Package3', 'Package3.Queries'],           data_files = [                        ('/etc/Package3', ['etc/Package3/ExternalResources.conf'])           ])


apt-get install python-stdeb

Python to Debian source package conversion utility

This package provides some tools to produce Debian 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 via a configuration file.

  • pypi-install will query the Python Package Index (PyPI) for apackage, download it, create a .deb from it, and then installthe .deb.
  • py2dsc will convert a distutils-built source tarball into a Debiansource package.


Most Python programs will use distutils. Django is a one - see http://code.djangoproject.com/svn/django/trunk/setup.py

You should also read the documentation, as it's very comprehensive and has some good examples.