[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Debian Python Policy [draft]



Please comment.

  Neil
                           Debian Python Policy
                           --------------------

                     Neil Schemenauer <nas@debian.org>

                                version 0.1


-------------------------------------------------------------------------------


Abstract
--------

     This document describes the packaging of Python within the Debian
     GNU/Linux distribution and the policy requirements for packaged Python
     programs and modules.


Copyright Notice
----------------

     Copyright (C) 2001 Software in the Public Interest

     This manual is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
     Free Software Foundation; either version 2 of the License, or (at your
     option) any later version.

     This is distributed in the hope that it will be useful, but WITHOUT
     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.

     A copy of the GNU General Public License is available as
     `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
     or on the World Wide Web at The GNU Public Licence
     (http://www.gnu.org/copyleft/gpl.html).

     You can also obtain it by writing to the Free Software Foundation,
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


-------------------------------------------------------------------------------


Contents
--------

     1.        Python Packaging
     1.1.      Stable and Legacy Versions
     1.2.      Module Path

     2.        Packaged Modules
     2.1.      Dependencies
     2.2.      Installation
     2.3.      Module Package Names

     3.        Python Programs
     3.1.      Version Independent Programs
     3.2.      Version Dependent Programs

     4.        Programs Embedding Python
     4.1.      Building Embedded Programs
     4.2.      Embedded Python Dependencies


-------------------------------------------------------------------------------


1. Python Packaging
-------------------


1.1. Stable and Legacy Versions
-------------------------------

     At any given time, the package `python' should represent the current
     stable upstream version of Python.

     Only one package may contain the `/usr/bin/python' binary and that
     package must either be `python' or a dependency of that package.

     The `python' package must provide `python-<X>.<Y>'; where <X> and <Y>
     represent the major and minor versions of the Python, respectively.

     There can be any number of legacy Python packages available.  These
     must be named `python-<X>.<Y>' and include the file
     `/usr/bin/python<X>.<Y>'.


1.2. Module Path
----------------

     Python searches a number of directories for modules.  The module
     search path for Debian has been ordered to include these locations at
     the beginning of the path in the following order:

          /usr/local/lib/site-python
          /usr/local/lib/python<X>.<Y>/site-packages
          /usr/lib/python<X>.<Y>/site-packages


-------------------------------------------------------------------------------


2. Packaged Modules
-------------------


2.1. Dependencies
-----------------

     Packaged modules must depend on `python-<X>.<Y>'.


2.2. Installation
-----------------

     Packaged modules must install into `/usr/lib/pythonX.Y/site-packages'.
     After installation, Python source files must be compiled.  This should
     be done with a `postint' script similar to the following example:

          #! /bin/sh -e
          
          PACKAGE=python-extension
          VERSION=<X>.<Y>
          LIB="/usr/lib/python$VERSION"
          DIRLIST="$LIB/site-packages/extension"
          
          case "$1" in
              configure|abort-upgrade|abort-remove|abort-deconfigure)
                  for i in $DIRLIST ; do
                      /usr/bin/python$VERSION -O $LIB/compileall.py -q $i
                      /usr/bin/python$VERSION $LIB/compileall.py -q $i
                  done
              ;;
          
              *)
                  echo "postinst called with unknown argument \`$1'" >&2
                  exit 1
              ;;
          esac

     Before removal of the package, the compiled files must be removed.
     This can be done with a `prerm' script similar to the following
     example:

          #! /bin/sh -e
          
          PACKAGE=python-extension
          
          dpkg --listfiles $PACKAGE |
                  awk '$0~/\.py$/ {print $0"c\n" $0"o"}' |
                  xargs rm -f >&2


2.3. Module Package Names
-------------------------

     Python module packages should be named for the primary module
     provided.  The naming convention for module `foo' is `python-foo'.
     Packages which include multiple modules may additionally include
     provides for those modules using the same convention.


-------------------------------------------------------------------------------


3. Python Programs
------------------


3.1. Version Independent Programs
---------------------------------

     Programs that can run with any version of Python must start with
     `#!/usr/bin/python'.  They must also specify a dependency on `python'.


3.2. Version Dependent Programs
-------------------------------

     Programs which require a specific version of Python must start with
     `#!/usr/bin/python<X>.<Y>'.  They must also specify a dependency on
     `python-<X>.<Y>'.


-------------------------------------------------------------------------------


4. Programs Embedding Python
----------------------------


4.1. Building Embedded Programs
-------------------------------

     Programs which embed a Python interpreter must declare a
     `Build-Depends' on `python-dev'.


4.2. Embedded Python Dependencies
---------------------------------

     Dependencies for programs linking against the shared Python library
     will be automatically created by `dpkg-shlibdeps'.


-------------------------------------------------------------------------------


     Debian Python Policy

     Neil Schemenauer <nas@debian.org>

     version 0.1


Reply to: