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


Debian Python Policy
Chapter 4 - Python Programs


4.1 Interpreter directive (“Shebang”)

Executables written for interpretation by Python must use an appropraite interpreter directive, or “shebang”, as the first line of the program. This line should be of the form #!interpreter_location. See Interpreter Name, Section 2.4.1 for the interpreter name to use.

As noted in Interpreter Location, Section 2.4.2, the form #!/usr/bin/env interpreter_name is deprecated.


4.2 Programs using the default Python

A package that installs a program that can be run by any version of Python 3 must declare a dependency on python3, with a versioned dependency if necessary.

A package that installs a program that can be run by any version of Python 2 must declare a dependency on python2, with a versioned dependency if necessary.

If the program needs the public Python module foo, the package must depend on the binary package that installs the foo module. See Module Package Names, Section 3.3 for the naming of packages that install public Python modules.


4.2.1 Programs Shipping Private Modules

A program that specifies python3 or python as its interpreter may require its own 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 3.7 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 post-install script using the current default Python version, and removed in the pre-remove script. 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: python3 (>= 3.5), python3 (<< 3.6).


4.3 Programs Using a Particular Python Version

A program which requires a specific minor version of Python must specify the versioned interpreter pythonX.Y. The package that installs the programs must also specify a dependency on pythonX.Y and on any packages that install necessary modules.

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 ] [ 6 ] [ A ] [ B ] [ C ] [ next ]


Debian Python Policy

version 0.10.1.1

Neil Schemenauer mailto:nas@debian.org
Matthias Klose mailto:doko@debian.org
Gregor Hoffleit mailto:flight@debian.org
Josselin Mouette mailto:joss@debian.org
Joe Wreschnig mailto:piman@debian.org
Loïc Minier mailto:lool@debian.org
Scott Kitterman mailto:scott@kitterman.com
Barry Warsaw mailto:barry@debian.org
Ben Finney mailto:ben+debian@benfinney.id.au