[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ A ] [ B ] [ C ] [ next ]

# Debian Python Policy
Chapter 3 - Python Programs

## 3.1 Programs using the default python

Programs that can run with any version of Python must begin with `#!/usr/bin/python` or `#!/usr/bin/env python` (the former is strongly preferred). They must also specify a dependency on `python`, with a versioned dependency if necessary.

If the program needs the python module `foo`, it must depend on the real package providing this module, usually `python-foo` but this name might vary when the package ships multiple modules.

### 3.1.1 Programs Shipping Private Modules

A program using `/usr/bin/python` as interpreter can come up with private Python modules. These modules should be installed in `/usr/share/module`, or `/usr/lib/module` if the modules are architecture-dependent (e.g. extensions).

The rules explained in Modules Byte-Compilation, Section 2.6 apply to those private modules: the byte-compiled modules must not be shipped with the binary package, they should be generated in the package's postinst, using the current default Python version, and removed in the prerm. Modules should be byte-compiled using the current default Python version.

Programs that have private compiled extensions must either handle multiple version support themselves, or declare a tight dependency on the current Python version (e.g. `Depends: python (>= 2.6), python (<< 2.7)`. No tools currently exist to alleviate this situation.

## 3.2 Programs Using a Particular Python Version

A program which requires a specific version of Python must begin with `#!/usr/bin/pythonX.Y` (or `#!/usr/bin/env pythonX.Y`). It must also specify a dependency on `pythonX.Y` and on any `pythonX.Y-foo` package providing necessary modules. It should not depend on any `python-foo` package, unless it requires a specific version of the package (since virtual packages cannot be versioned). If this is the case, it should depend on both the virtual package and the main package (e.g. `Depends: python2.7-foo, python-foo (>= 1.0)`).

The notes on installation directories and byte-compilation for programs that support any version of Python also apply to programs supporting only a single Python version. Modules to be byte-compiled should use the same Python version as the package itself.

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ A ] [ B ] [ C ] [ next ]

Debian Python Policy