From 8bd6d7a834dddfd32f8d6be7b202822661414404 Mon Sep 17 00:00:00 2001 From: Matthias Klose <doko@timbuktu> Date: Mon, 17 May 2010 12:57:24 +0200 Subject: [PATCH] package version python-defaults-2.4.3-02 --- debian/README.Tk | 8 - debian/changelog | 59 +- debian/control | 47 +- debian/control.in | 23 +- debian/control.in.all | 30 - debian/debian_defaults | 2 +- ...ython.postinst => python-minimal.postinst} | 5 + .../{python.postrm => python-minimal.postrm} | 2 +- debian/python-minimal.preinst | 10 + debian/{python.prerm => python-minimal.prerm} | 2 +- debian/python-policy.sgml | 757 ++++++++++-------- debian/python.preinst | 7 - debian/pyversions | 6 + debian/pyversions.1 | 13 +- debian/pyversions.py | 110 +-- debian/rules | 63 +- 16 files changed, 549 insertions(+), 595 deletions(-) delete mode 100644 debian/README.Tk delete mode 100644 debian/control.in.all rename debian/{python.postinst => python-minimal.postinst} (64%) rename debian/{python.postrm => python-minimal.postrm} (67%) create mode 100644 debian/python-minimal.preinst rename debian/{python.prerm => python-minimal.prerm} (53%) create mode 100755 debian/pyversions diff --git a/debian/README.Tk b/debian/README.Tk deleted file mode 100644 index 7067ecb..0000000 --- a/debian/README.Tk +++ /dev/null @@ -1,8 +0,0 @@ -Tkinter documentation can be found at - - http://www.pythonware.com/library/index.htm - -more specific: - - http://www.pythonware.com/library/tkinter/introduction/index.htm - http://www.pythonware.com/library/tkinter/an-introduction-to-tkinter.pdf diff --git a/debian/changelog b/debian/changelog index 483e972..e263f59 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,65 +1,34 @@ -python-defaults (2.3.5-11) unstable; urgency=low +python-defaults (2.4.3-02) experimental; urgency=low - * pyversions -r: If the XS-Python-Version field cannot be found in - debian/control, fall back to debian/pyversions for the version - information. Return with an error code, if the intersection of - the versions in debian/pyversions and the supported python versions - is empty. Fall back to the supported versions if no version - information can be found. Based on a patch from Raphael Hertzog. + * Really do not build python-doc. - -- Matthias Klose <doko@debian.org> Thu, 22 Jun 2006 23:28:32 +0200 + -- Matthias Klose <doko@debian.org> Sun, 11 Jun 2006 23:25:02 +0000 -python-defaults (2.3.5-10) unstable; urgency=low +python-defaults (2.4.3-01) experimental; urgency=low - * Tighten dependencies between packages built from this source. - A versioned dependency on python-all / python-all-dev is enough - to depend on the same version of python / python-dev. - * python: Conflict with python-central (<< 0.4.17). - * python: Depend on a python2.3 built for the updated Python policy. - * python: Conflict with a python2.4 using the old Python policy. - - -- Matthias Klose <doko@debian.org> Thu, 15 Jun 2006 22:05:04 +0200 - -python-defaults (2.3.5-9) unstable; urgency=low - - * python-all: Depend on python as well. - - -- Matthias Klose <doko@debian.org> Wed, 14 Jun 2006 00:45:46 +0000 - -python-defaults (2.3.5-8) unstable; urgency=low - - * Include version 0.4.1.0 of the python policy. - * Fix 'pyversions -i'. - - -- Matthias Klose <doko@debian.org> Tue, 13 Jun 2006 09:44:22 +0200 - -python-defaults (2.3.5-7) unstable; urgency=low - - * Point to the draft of the reworked Python policy. - * Fix 'pyversions -r current' (Raphael Hertzog). + * Do not build the python-doc package from this source. - -- Matthias Klose <doko@debian.org> Mon, 12 Jun 2006 13:38:41 +0200 + -- Matthias Klose <doko@debian.org> Sun, 11 Jun 2006 23:59:17 +0200 -python-defaults (2.3.5-6) unstable; urgency=low +python-defaults (2.4.3-0) experimental; urgency=low - * Last 2.3.5 upload, 2.4.3 can be found in experimental. - * Do not build the python-mpz, python-tk and python-gdbm packages from - this source. + * Upload to experimental. + * Do not build the python-tk and python-gdbm packages from this source. * Let the -all packages depend on the default packages (closes: #365219). * Add /usr/share/python/debian_defaults for some default values (i.e. the supported python versions). * Add /etc/python/debian_config for byte-compilation options. * Add a pyversions script to give information about python versions and parse the XS-Python-Version attribute. - * Do not build the python-doc package from this source. - -- Matthias Klose <doko@debian.org> Sun, 11 Jun 2006 23:42:42 +0200 + -- Matthias Klose <doko@debian.org> Sun, 11 Jun 2006 12:57:03 +0000 -python-defaults (2.3.5-5) unstable; urgency=low +python-defaults (2.4.2-1) unstable; urgency=low - * Fix upgrade issues (closes: #348319, #348354). + * Change the default python version to 2.4. + * Depend on python-central. - -- Matthias Klose <doko@debian.org> Mon, 16 Jan 2006 16:50:11 +0000 + -- Matthias Klose <doko@debian.org> Thu, 12 Jan 2006 01:16:10 +0000 python-defaults (2.3.5-4) unstable; urgency=low diff --git a/debian/control b/debian/control index 0aa5a71..39ec21a 100644 --- a/debian/control +++ b/debian/control @@ -2,52 +2,50 @@ Source: python-defaults Section: python Priority: optional Maintainer: Matthias Klose <doko@debian.org> -Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils -Standards-Version: 3.6.2 +Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils, python, python2.4 +Standards-Version: 3.7.2 Package: python Architecture: all Priority: standard -Depends: python2.3 (>= 2.3.5-14) -Conflicts: python2.3 (<= 2.3.2-6), python2.4 (<< 2.4.3-7), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.4.17) +Depends: python2.4 (>= 2.4.3), python-minimal (= ${Source-Version}) +Conflicts: python2.3 (<= 2.3.2-6), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base Replaces: python2.3 (<= 2.3.2-6), python-xmlbase, python-base Provides: python-email, python-xmlbase Suggests: python-doc, python-tk, python-profiler -Enhances: konsole Description: An interactive high-level object-oriented language (default version) Python, the high-level, interactive object oriented language, includes an extensive class library with lots of goodies for network programming, system administration, sounds and graphics. . This package is a dependency package, which depends on Debian's default - Python version (currently v2.3). + Python version (currently v2.4). Package: python-minimal Architecture: all Priority: standard -Depends: python2.3 (>= 2.3.5-14) +Depends: python2.4-minimal (>= 2.4.3), python-central (>= 0.4.7), dpkg (>= 1.13.20) +Conflicts: python (<= 2.4-1) +Replaces: python (<= 2.4-1) Description: A minimal subset of the Python language (default version) This package contains the interpreter and some essential modules. It's used in the boot process for some basic tasks. See /usr/share/doc/python-minimal/README.Debian for a list of the modules contained in this package. - . - NOTE: There is no python2.3-minimal package yet, this package will depend - on the python2.4-minimal package after a change of the default python version. Package: python-examples Architecture: all -Depends: python (= ${Source-Version}), python2.3-examples (>= 2.3.5-14) +Depends: python (= ${Source-Version}), python (<< 2.5), python2.4-examples (>= 2.4.3) Description: Examples for the Python language (default version) Examples, Demos and Tools for Python. These are files included in the upstream Python distribution. . This package is a dependency package, which depends on Debian's default - Python version (currently v2.3). + Python version (currently v2.4). Package: python-dev Architecture: all -Depends: python (= ${Source-Version}), python2.3-dev (>= 2.3.5-14) +Depends: python (= ${Source-Version}), python2.4-dev (>= 2.4.3) Description: Header files and a static library for Python (default) Header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python @@ -57,29 +55,28 @@ Description: Header files and a static library for Python (default) version 1.5.2. . This package is a dependency package, which depends on Debian's default - Python version (currently v2.3). + Python version (currently v2.4). Package: idle Architecture: all -Depends: python (= ${Source-Version}), idle-python2.3 (>= 2.3.5-14) -Enhances: python +Depends: python (= ${Source-Version}), idle-python2.4 (>= 2.4.3) Description: An IDE for Python using Tkinter (default version) IDLE is an Integrated Development Environment for Python. IDLE is written using Tkinter and therefore quite platform-independent. . This package is a dependency package, which depends on Debian's default - Python version (currently v2.3). + Python version (currently v2.4). Package: python-doc Section: doc Architecture: all -Depends: python2.3-doc (>= 2.3.5-14) +Depends: python2.4-doc (>= 2.4.3) Suggests: python Conflicts: python-doc-info, python (<< 2.3.5) Replaces: python-doc-info, python (<< 2.3.5) Description: Documentation for the high-level object-oriented language Python This is the official set of documentation for the interactive high-level - object-oriented language Python (v2.3). All documents are provided + object-oriented language Python (v2.4). All documents are provided in HTML format, some in info format. The package consists of nine documents: . * Tutorial @@ -93,15 +90,15 @@ Description: Documentation for the high-level object-oriented language Python * Distributing Python Modules . This package is a dependency package, which depends on Debian's default - Python version (currently v2.3). + Python version (currently v2.4). Package: python-dbg Architecture: all Priority: extra -Depends: python (= ${Source-Version}), python2.3-dbg (>= 2.3.5-14) -Description: Debug Build of the Python Interpreter (version 2.3) +Depends: python (= ${Source-Version}), python2.4-dbg (>= 2.4.3) +Description: Debug Build of the Python Interpreter (version 2.4) Python interpreter configured with --pydebug. Dynamically loaded modules are - searched in /usr/lib/python2.3/lib-dynload/debug first. + searched in /usr/lib/python2.4/lib-dynload/debug first. Package: python-all Architecture: all @@ -118,9 +115,9 @@ Description: Package depending on all supported Python runtime versions Package: python-all-dev Architecture: all Priority: optional -Depends: python-all (= ${Source-Version}), python-dev (= ${Source-Version}), python2.3-dev, python2.4-dev +Depends: python-all (= ${Source-Version}), python-dev, python2.3-dev, python2.4-dev Description: Package depending on all supported Python development packages - The package currently depends on python2.3-dev and python2.4-dev, in the + The package currently depends on python2.4-dev, in the future, dependencies on jython (Python for a JVM) and ironpython (Python for Mono) may be added. . diff --git a/debian/control.in b/debian/control.in index a316c6a..1a07700 100644 --- a/debian/control.in +++ b/debian/control.in @@ -2,18 +2,17 @@ Source: python-defaults Section: python Priority: optional Maintainer: Matthias Klose <doko@debian.org> -Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils -Standards-Version: 3.6.2 +Build-Depends-Indep: debhelper (>= 4), libhtml-tree-perl, debiandoc-sgml, python-docutils, python, python2.4 +Standards-Version: 3.7.2 Package: python Architecture: all Priority: standard -Depends: @PVER@ (>= @PREVVER@) -Conflicts: python2.3 (<= 2.3.2-6), python2.4 (<< 2.4.3-7), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.4.17) +Depends: @PVER@ (>= @PREVVER@), python-minimal (= ${Source-Version}) +Conflicts: python2.3 (<= 2.3.2-6), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base Replaces: python2.3 (<= 2.3.2-6), python-xmlbase, python-base Provides: python-email, python-xmlbase Suggests: python-doc, python-tk, python-profiler -Enhances: konsole Description: An interactive high-level object-oriented language (default version) Python, the high-level, interactive object oriented language, includes an extensive class library with lots of goodies for @@ -25,19 +24,18 @@ Description: An interactive high-level object-oriented language (default version Package: python-minimal Architecture: all Priority: standard -Depends: @PVER@ (>= @PREVVER@) +Depends: @PVER@-minimal (>= @PREVVER@), python-central (>= 0.4.7), dpkg (>= 1.13.20) +Conflicts: python (<= 2.4-1) +Replaces: python (<= 2.4-1) Description: A minimal subset of the Python language (default version) This package contains the interpreter and some essential modules. It's used in the boot process for some basic tasks. See /usr/share/doc/python-minimal/README.Debian for a list of the modules contained in this package. - . - NOTE: There is no python2.3-minimal package yet, this package will depend - on the python2.4-minimal package after a change of the default python version. Package: python-examples Architecture: all -Depends: python (= ${Source-Version}), @PVER@-examples (>= @PREVVER@) +Depends: python (= ${Source-Version}), python (<< @NVER@), @PVER@-examples (>= @PREVVER@) Description: Examples for the Python language (default version) Examples, Demos and Tools for Python. These are files included in the upstream Python distribution. @@ -62,7 +60,6 @@ Description: Header files and a static library for Python (default) Package: idle Architecture: all Depends: python (= ${Source-Version}), idle-@PVER@ (>= @PREVVER@) -Enhances: python Description: An IDE for Python using Tkinter (default version) IDLE is an Integrated Development Environment for Python. IDLE is written using Tkinter and therefore quite platform-independent. @@ -118,9 +115,9 @@ Description: Package depending on all supported Python runtime versions Package: python-all-dev Architecture: all Priority: optional -Depends: python-all (= ${Source-Version}), python-dev (= ${Source-Version}), python2.3-dev, python2.4-dev +Depends: python-all (= ${Source-Version}), python-dev, python2.3-dev, python2.4-dev Description: Package depending on all supported Python development packages - The package currently depends on python2.3-dev and python2.4-dev, in the + The package currently depends on python2.4-dev, in the future, dependencies on jython (Python for a JVM) and ironpython (Python for Mono) may be added. . diff --git a/debian/control.in.all b/debian/control.in.all deleted file mode 100644 index 66ae926..0000000 --- a/debian/control.in.all +++ /dev/null @@ -1,30 +0,0 @@ - - * Add two dependency packages python-all and python-all-dev. These - packages are used as build dependencies to determine the set of - python version and implementations, which should be supported. - Currently it depends on python2.3 and python2.4. Future versions - may add an updated version of jython and ironpython. - -Package: python-all -Architecture: all -Priority: optional -Depends: python2.3, python2.4 -Description: Package depending on all supported Python runtime versions - The package currently depends on python2.3 and python2.4, in the future, - dependencies on jython (Python for a JVM) and ironpython (Python for Mono) - may be added. - . - This package is mostly used as a build dependency for other packages to - avoid hardcoded dependencies on specific Python runtimes. - -Package: python-all-dev -Architecture: all -Priority: optional -Depends: python-all (>= @VER@), python2.3-dev, python2.4-dev -Description: Package depending on all supported Python development packages - The package currently depends on python2.3-dev and python2.4-dev, in the - future, dependencies on jython (Python for a JVM) and ironpython (Python - for Mono) may be added. - . - This package is mostly used as a build dependency for other packages to - avoid hardcoded dependencies on specific Python development packages. diff --git a/debian/debian_defaults b/debian/debian_defaults index 4bee8be..5450bd8 100644 --- a/debian/debian_defaults +++ b/debian/debian_defaults @@ -1,3 +1,3 @@ [DEFAULT] -default-version = python2.3 +default-version = python2.4 supported-versions = python2.3, python2.4 diff --git a/debian/python.postinst b/debian/python-minimal.postinst similarity index 64% rename from debian/python.postinst rename to debian/python-minimal.postinst index 6c6a464..9ac1be6 100644 --- a/debian/python.postinst +++ b/debian/python-minimal.postinst @@ -13,6 +13,11 @@ case "$1" in configure) [ -d /etc/python ] || mkdir /etc/python [ -f /etc/python/debian_config ] || new_config_file + + if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.4; then + oldv=$(echo $2 | sed 's/^\(...\).*/\1/') + pycentral updatedefault python$oldv python2.4 + fi esac #DEBHELPER# diff --git a/debian/python.postrm b/debian/python-minimal.postrm similarity index 67% rename from debian/python.postrm rename to debian/python-minimal.postrm index fde8ddd..a818ee3 100644 --- a/debian/python.postrm +++ b/debian/python-minimal.postrm @@ -2,7 +2,7 @@ case "$1" in purge) - rm -rf /etc/python + rm -rf /etc/python esac #DEBHELPER# diff --git a/debian/python-minimal.preinst b/debian/python-minimal.preinst new file mode 100644 index 0000000..977f58f --- /dev/null +++ b/debian/python-minimal.preinst @@ -0,0 +1,10 @@ +#! /bin/sh -e + +# remove the python alternatives before installing our own python link + +update-alternatives --auto /usr/bin/python >/dev/null 2>&1 || true +update-alternatives --remove python /usr/bin/python1.5 || true +update-alternatives --remove python /usr/bin/python2.1 || true +update-alternatives --remove python /usr/bin/python2.2 || true + +#DEBHELPER# diff --git a/debian/python.prerm b/debian/python-minimal.prerm similarity index 53% rename from debian/python.prerm rename to debian/python-minimal.prerm index 4947b74..cafed8e 100644 --- a/debian/python.prerm +++ b/debian/python-minimal.prerm @@ -2,7 +2,7 @@ case "$1" in remove) - rm -f /usr/share/python/pyversions.py[co] + rm -f /usr/share/python/pyversions.py[co] esac #DEBHELPER# diff --git a/debian/python-policy.sgml b/debian/python-policy.sgml index 5b5e3c2..800e9b6 100644 --- a/debian/python-policy.sgml +++ b/debian/python-policy.sgml @@ -20,11 +20,7 @@ <name>Josselin Mouette</name> <email>joss@debian.org</email> </author> - <author> - <name>Joe Wreschnig</name> - <email>piman@debian.org</email> - </author> - <version>version 0.4.1.0</version> + <version>version 0.3.7.2</version> <abstract> This document describes the packaging of Python within the @@ -34,8 +30,7 @@ <copyright> <copyrightsummary> - Copyright © 1999, 2001, 2003, 2006 Software in the - Public Interest + Copyright © 1999, 2001, 2003 Software in the Public Interest </copyrightsummary> <p> This manual is free software; you can redistribute it and/or @@ -91,12 +86,9 @@ </p> <p> For any version, the main package must be called - <package>python<var>X</var>.<var>Y</var></package>. - </p> - - <p> - The set of currently supported python versions can be found - in <file>/usr/share/python/debian_defaults</file>. + <package>python<var>X</var>.<var>Y</var></package>. Names of + related packages must include the + <package>python<var>X</var>.<var>Y</var></package> part. </p> </sect> @@ -133,6 +125,7 @@ </p> </sect> + <sect id="interpreter"> <heading>Python Interpreter</heading> <sect1 id="interpreter_name"> @@ -144,7 +137,7 @@ </p> <p> Python scripts that only work with a specific Python version must - explicitly use the versioned interpreter name + explicitely use the versioned interpreter name (<file>python<var>X</var>.<var>Y</var></file>). </p> </sect1> @@ -169,6 +162,8 @@ </sect1> </sect> + + <sect id="paths"> <heading>Module Path</heading> <p> @@ -177,27 +172,43 @@ the path. By default, sys.path is searched in the following order: <example> -/usr/lib/python<var>XY</var>.zip +/usr/lib/python<var>X</var>.<var>Y</var>.zip /usr/lib/python<var>X</var>.<var>Y</var> /usr/lib/python<var>X</var>.<var>Y</var>/plat-linux2 /usr/lib/python<var>X</var>.<var>Y</var>/lib-tk /usr/lib/python<var>X</var>.<var>Y</var>/lib-dynload /usr/local/lib/python<var>X</var>.<var>Y</var>/site-packages /usr/lib/python<var>X</var>.<var>Y</var>/site-packages -/var/lib/python-support/python<var>X</var>.<var>Y</var> /usr/lib/python<var>X</var>.<var>Y</var>/site-packages/<var>module-dir</var> /usr/lib/site-python </example> </p> <p> - The use of the <file>/usr/lib/site-python</file> directory - is deprecated. The directory may be dropped from the path in - a future version. The /usr/lib/python<var>XY</var>.zip - archive appeared in python2.3; it is not currently used in - Debian. Modules should not install directly to the - <file>/var/lib/python-support</file> directory; it is for - use by <ref id="pysupport">. + Note that the use of the site-python directories in Python is + depreciated. The directories might be dropped from the path in a + future version. + </p> + <p> + The /usr/lib/python<var>X</var>.<var>Y</var>.zip archive + appeared in python2.3. </p> + + <p> + TODO: in fact this directory was not deprecated at all, and is + widely used for shipping modules for the default python version. + It has been suggested to automatically bytecompile modules in this + directory for the current python version, which is technically + feasible and would make it a place of choice for version-independent + python modules (e.g. for modules shipped with a single script). + </p> + + <p> + TODO: What about + <file>/usr/share/python<var>X</var>.<var>Y</var></file>? + Wait for upstream ... see <url id="http://python.org/sf/588756" + name="http://python.org/sf/588756">. + </p> + </sect> <sect id="docs"> @@ -216,142 +227,249 @@ <chapt id="module_packages"> <heading>Packaged Modules</heading> - <p> - The goal of these policies is to reduce the work necessary for - Python transitions. Python modules are internally very - dependent on a specific Python version. However, we want to - automate recompiling modules when possible, either during the - upgrade itself (re-bytecompiling pyc and pyo files) or shortly - thereafter with automated rebuilds (to handle C - extensions). These policies encourage automated dependency - generation and loose version bounds whenever possible. + <sect> - <heading>Types of Python Modules</heading> - <p> - There are two kinds of Python modules, "pure" Python - modules, and extension modules. Pure Python modules are - Python source code that works across many versions of - Python. Extensions are C code compiled and linked against a - specific version of the libpython library, and so can only - be used by one version of Python. - </p> - <p> - Python packages are directories containing at least a - <file>__init__.py</file>, other modules, extensions and - packages (A package in the Python sense is unrelated to a - Debian package). Python packages must be packaged into the - same directory (as done by upstream). Splitting components - of a package across directories changes the import order and - may confuse documentation tools and IDEs. - </p> - <p> - There are two ways to distribute Python modules. Public - modules are installed in one of the directories listed - in <ref id="paths">. They are accessible to any - program. Private modules are installed in a directory such - as <file>/usr/share/<var>packagename</var></file> - or <file>/usr/lib/<var>packagename</var></file>. They are - generally only accessible to a specific program or suite of - programs included in the same package. + <heading>Rationale: A different view</heading> + <p> + A package with a name + <package>python-<var>foo</var></package> will always + provide the module <var>foo</var> for the default Debian + Python version of the distribution. I.e. the package will + extend the function of <file>/usr/bin/python</file> (which + is installed by the package <package>python</package>). </p> - </sect> - <sect id="package_names"> - <heading>Module Package Names</heading> <p> - Public modules should be packaged with a name - of <package>python-<var>foo</var></package>, - where <var>foo</var> is the name of the module. Such a - package should support the current Debian Python version, - and more if possible (there are several tools to help - implement this, see <ref id="packaging_tools">). For - example, if Python 2.3, 2.4, and 2.5 are supported, the - Python command - <example> -import foo - </example> - should import the module when the user is running any - of <prgn>/usr/bin/python2.3</prgn>, <prgn>/usr/bin/python2.4</prgn>, - and <prgn>/usr/bin/python2.5</prgn>. This requirement also - applies to extension modules; binaries for all the supported - Python versions should be included in a single package. - </p> - </sect> - <sect id="specifying_versions"> - <heading>Specifying Supported Versions</heading> - <p> - The <tt>XS-Python-Version</tt> field - in <file>debian/control</file> specifies the versions of - Python supported by the package. This is used to track - packages during Python transitions, and is also used by some - packaging scripts to automatically generate appropriate - Depends and Provides lines. The format of the field may be - one of the following: - <example> -XS-Python-Version: all -XS-Python-Version: current -XS-Python-Version: current, >= X.Y -XS-Python-Version: >= X.Y -XS-Python-Version: >= A.B, << X.Y -XS-Python-Version: A.B, X.Y - </example> - Where "all" means the package supports any Python version - available, and "current" means it supports Debian's current - Python version. Explicit Versions or version ranges can also - be used. + The system of dependencies of the default packages is robust + against upgrades, but introduces a strong dependency: + I.e. an upgrade of the <package>python</package> package + will be hold back as long as there are still default modules + packages left over on the system that can't be upgraded to + the new version. </p> <p> - Your control file should also have a line: - <example> -XB-Python-Version: ${python:Versions} - </example> - The python:Versions is substituted by the supported Python - versions of the binary package, based on - <tt>XS-Python-Version</tt>. (If you are not using - <prgn>dh_python</prgn> you will need to handle this - substitution yourself.) The format of the field - <tt>XB-Python-Version</tt> is the same as the - <tt>XS-Python-Version</tt> field for packages not containing - extensions. Packages with extensions must list the versions - explicitely. - </p> - <p> - If your package is used by another module or application - that requires a specific Python version, it should also - <tt>Provide: python<var>X</var>.<var>Y</var>-foo</tt> for - each version it supports. + The versioned packages (legacy versions) ensure that an + upgrade to a new version can take place before upgrading + *all* packages with dependencies on Python. </p> </sect> - <sect id="dependencies"> - <heading>Dependencies</heading> + <sect id="variants"> + <heading>Packaging Variants</heading> + <p> + There is more than one way to package a Python module: + <enumlist> + <item> + <p> + Support only the default Python version. + </p> + </item> + <item> + <p> + Support a particular version, or some but not all versions of + Python available in Debian. + </p> + </item> + <item> + <p> + Support all/most versions of python, including the default. + This variant is still not completely supported. + </p> + </item> + </enumlist> + </p> + + <sect1 id="default_version"> + <heading>Support Only The Default Version</heading> + <p> + Name your package + <package>python-<var>foo</var></package>. This kind of + package is called a <em>default module package</em>. + Install your modules into + <file>/usr/lib/python<var>X</var>.<var>Y</var>/site-packages/</file>. + Make your package dependency look like + <example> +Depends: python (>= X.Y), python (<< X.Y+1) + </example> + Note that this kind of packaging means that your package will + trigger a conflict when the default Debian Python version in the + distribution is changed, and that you will have to provide a new + version as soon as possible, since the package will block the + upgrade of <package>python</package>. + </p> + <p> + You should not make a default, unversioned module package + <package>python-<var>foo</var></package> depend on the + versioned Python package + <package>python<var>X</var>.<var>Y</var></package>! + </p> + <p> + If the build process uses distutils and/or binary modules are built, + the source package must declare: + <example> +Build-Depends: pythonX.Y-dev + </example> + where <var>X</var>.<var>Y</var> is the version used in + the <tt>Depends</tt>. + If the packaging process can deal with later versions of python + without any changes to the packaging, it can instead declare: + <example> +Build-Depends: python-dev (>= X.Y) + </example> + When the default python version is changed, these packages + still need to be rebuilt, if modules are installed in a + module path specific to the python version. + </p> + <p> + Any scripts and examples provided in the package should use + <file>/usr/bin/python</file> as interpreter. + </p> + <p> + TODO: Should a <package>python-foo</package> provide + <package>python<var>X</var>.<var>Y</var>-foo</package>, + provided that the Debian policy allows us to create such a + mass of virtual packages? + </p> + + </sect1> + + <sect1 id="particular_version"> + <heading>Support one or several Particular Version(s)</heading> + <p> + For each python<var>X</var>.<var>Y</var> version you want to + support, name the package + <package>python<var>X</var>.<var>Y</var>-<var>foo</var></package> + (a <em>versioned module package</em>). Make the dependency + look like + <example> +Depends: python<var>X</var>.<var>Y</var> + </example> + Each of them should install modules somewhere inside + <file>/usr/lib/python<var>X</var>.<var>Y</var>/site-packages/</file>. + Any included scripts and examples should use + <file>/usr/bin/python<var>X</var>.<var>Y</var></file> as + interpreter. + </p> + <p> + If necessary, the packaged source must declare + <example> +Build-Depends: pythonX.Y-dev, ... + </example> + including all <var>X</var>.<var>Y</var> supported versions. + </p> + </sect1> + + <sect1 id="all_versions"> + <heading>Support All/Most Versions (Including Default)</heading> + <p> + This option is recommended for most modules packages. There are two + different cases: + <enumlist> + <item> + <p>Multiple versioned packages</p> + <p> + You have binary extensions that must be compiled + against particular versions of Python. Create + multiple + <package>python<var>X</var>.<var>Y</var>-<var>foo</var></package> + packages as in <ref id="particular_version">. Also + create an empty default package + <package>python-<var>foo</var></package> with + <example> +Depends: python (>= X.Y), python (<< X.Y+1), pythonX.Y-foo + </example> + Note that this kind of packaging means that the + default package will trigger a conflict when the + default Debian Python version in the distribution is + changed, and that you will have to provide a new + version of your package as soon as possible, since + the package will block the upgrade of + <package>python</package>. + </p> + <p> + The packaged sources <tt>Build-Depends</tt> must contain all + <package>python<var>X</var>.<var>Y</var>-dev</package> + packages that the module is built for. + </p> + </item> + + <item>A single package for all versions (NOT YET SUPPORTED!) + <p> + You have a version independent Python module. Create + a single package + <package>python-<var>foo</var></package> that has a + dependency + <example> +Depends: python + </example> + It should install modules somewhere inside + <file>/usr/lib/python/site-packages/</file> and use + <tt>#!/usr/bin/python</tt> for programs. The + <file>postinst</file> script should create symlinks + in all + <file>/usr/lib/pythonX.Y/site-packages/</file> + directories that point to its + <file>/usr/lib/python/site-packages/</file> files + and compile them. + </p> + <p> + NOT YET SUPPORTED: It's errorprone if the package itself + supplies these scripts. And the package cannot know when a + new upstream Python version is installed. So the + <package>python<var>X</var>.<var>Y</var></package> must + provide these scripts, which is not yet done. + </p> + <p> + The packaged source must declare + <tt>Build-Depends</tt> on one + <package>python<var>X</var>.<var>Y</var>-dev</package> + package. XXX: Or build-depend on each Python + version, so that only checked modules are uploaded? + </p> + <p> + TODO: Should policy demand that these packages must have a + dependency on <package>python (<= + <var>X</var>.<var>Y+1</var></package>)? + </p> + </item> + </enumlist> + + </p> + </sect1> + </sect> + + <sect id="package_names"> + <heading>Module Package Names</heading> <p> - Packaged modules available for the default Python version - (or many versions including the default) as described - in <ref id="package_names"> must depend on "<package>python - (>= <var>X</var>.<var>Y</var></package>)". If they - require other modules to work, they must depend on the - corresponding <package>python-foo</package>. They must not - depend on - any <package>python<var>X</var>.<var>Y</var>-foo</package>. + Python module packages should be named for the primary module + provided. The naming convention for a module <tt>Foo</tt> is + <package>python-<var>foo</var></package> for the package for the + default Python version (the <em>default module package</em>). + (Packages which include multiple modules may additionally include + provides for those modules using the same convention.) </p> <p> - Packaged modules available for one particular version of Python must - depend on the corresponding - <package>python<var>X</var>.<var>Y</var></package> package instead. - If they need other modules, they must depend on the corresponding - <package>python<var>X</var>.<var>Y</var>-foo</package> packages, and - must not depend on any <package>python-foo</package>. + Python module packages packaged for one particular version of Python + (<em>versioned modules packages</em>) should be named + <package>python<var>X</var>.<var>Y</var>-foo</package>. + </p> + <p> + A module package providing a module for python version, + which is not the default python version, must not be named + <package>python-<var>foo</var></package>, it has to be named + <package>python<var>X</var>.<var>Y</var>-foo</package>. </p> </sect> - <sect id="provides"> - <heading>Provides</heading> + <sect id="dependencies"> + <heading>Dependencies</heading> <p> - Provides in packages of the form - <package>python-<var>foo</var></package> must be specified, - if the package contains an extension for more than one - python version. Provides should also be added on request of - maintainers who depend on a non-default python version. + Packaged modules available for the default Python version as + described in <ref id="default_version"> must depend on + "<package>python (>= <var>X</var>.<var>Y</var>), + python (<< <var>X</var>.<var>Y+1</var>)</package>". + If they require other modules to work, they must depend on the + corresponding <package>python-foo</package>. They must not depend + on any <package>python<var>X</var>.<var>Y</var>-foo</package>. </p> <p> Packaged modules available for one particular version of Python must @@ -367,30 +485,36 @@ XB-Python-Version: ${python:Versions} <heading>Modules Bytecompilation</heading> <p> If a package provides any binary-independent modules - (<file>foo.py</file> files), the corresponding bytecompiled - modules (<file>foo.pyc</file> files) and optimized modules - (<file>foo.pyo</file> files) must not ship in the - package. Instead, they should be generated in the package's - postinst, and removed in the package's prerm. The package's - prerm has to make sure that both <file>foo.pyc</file> and - <file>foo.pyo</file> are removed. - </p> - <p> - A package should only byte-compile the files which belong to - the package. - </p> - <p> - The file <file>/etc/python/debian_config</file> allows - configuration how modules should be byte-compiled. The - postinst scripts should respect these settings. + (<file>foo.py</file> files), the corresponding bytecompiled modules + (<file>foo.pyc</file> files) and optimized modules (<file>foo.pyo</file> + files) must not be shipped in the package. Instead, they should be + generated at the package post-installation, using e.g. + <example> +PYTHON=python2.3 +if which $PYTHON >/dev/null 2>&1; then + DIRLIST="/usr/lib/python2.3/site-packages" + for i in $DIRLIST ; do + $PYTHON -E -O /usr/lib/$PYTHON/compileall.py -q $i + $PYTHON -E /usr/lib/$PYTHON/compileall.py -q $i + done +fi + </example> + and removed in the package's pre-removal script, e.g. + <example> +dpkg -L python2.3-somemodule | + awk '$0~/\.py$/ {print $0"c\n" $0"o"}' | + xargs rm -f >&2 + </example> </p> <p> - Modules in private installation directories and in - <file>/usr/lib/site-python</file> should be byte-compiled, - when the default python version changes. + If you use debhelper, it is a good idea to use <tt>dh_python</tt> + just before <tt>dh_installdeb</tt>, in which case you must + Build-depend on <package>debhelper (>= 4.1.67)</package>. + It removes undesired files and generates those scripts automatically. + It also helps automating the package's dependencies generation, + using the <tt>${python:Depends}</tt> substitution variable. </p> </sect> - </chapt> <chapt id="programs"> <heading>Python Programs</heading> @@ -398,77 +522,116 @@ XB-Python-Version: ${python:Versions} <sect id="version_indep_progs"> <heading>Programs using the default python</heading> <p> - Programs that can run with any version of Python must - begin with <tt>#!/usr/bin/python</tt> or <tt>#!/usr/bin/env - python</tt> (the former is preferred). They must also - specify a dependency on <package>python</package>, with a - versioned dependency if necessary. + Programs that can run with any version of Python should be started + with <tt>#!/usr/bin/python</tt>. They must also specify a + dependency on <package>python</package>, with a versioned dependency + if necessary. </p> <p> - If the program needs the python module <tt>foo</tt>, - it must depend on <package>python-foo</package>. + If the program needs the python module <tt>Foo</tt>, + it must depend on <package>python-foo</package>. In the case + where <package>python-foo</package> does not exist, but a + <package>python<var>X</var>.<var>Y</var>-foo</package> package + exists for the current python version, it can depend on + "<package>python<var>X</var>.<var>Y</var>-foo, + python (>= <var>X</var>.<var>Y</var>), + python (<< <var>X</var>.<var>Y+1</var>)</package>" + so that dependencies are robust upon the next major python upgrade. + </p> + <p> + You're free to use <tt>#!/usr/bin/env python</tt>, if you'd like to + give the user a chance to override the Debian Python package with a + local version, but it is not recommended. </p> <sect1 id="current_version_progs"> <heading>Programs Shipping Private Modules</heading> <p> A program using <file>/usr/bin/python</file> as - interpreter can come up with private Python modules. These + interpreter can come up with private python modules. These modules should be installed in - <tt>/usr/share/<var>module</var></tt>, or - <tt>/usr/lib/<var>module</var></tt> if the modules are - architecture-dependent (e.g. extensions). + <tt>/usr/lib/site-python/<var>module</var></tt>, + <tt>/usr/lib/python<var>X</var>.<var>Y</var>/site-packages/<var>module</var></tt> + (where python<var>X</var>.<var>Y</var> is the current + python version). + </p> + <p> + If the private modules would pollute the name space in + <tt>sys.path</tt>, the modules should be installed in + <tt>/usr/lib/<var>package</var></tt> (for architecture + any) or <tt>/usr/share/<var>package</var></tt> (for + architecture all). In this case, the directory should be + added to <tt>sys.path</tt> at the program startup. </p> <p> - <file>/usr/lib/site-python</file> is deprecated and should - no longer be used for this purpose. + Such a package must depend on + "<package>python (>= <var>X</var>.<var>Y</var>), + python (<< <var>X</var>.<var>Y+1</var>)</package>". </p> <p> The rules explained in <ref id="bytecompilation"> apply to those private modules: the bytecompiled modules must not be shipped with the package, they should be generated in - the package's postinst, using the current default Python - version, and removed in the prerm. Modules should be - bytecompiled using the current default Python version. + the package's postinst, using the current default python + version, and removed in the prerm. </p> <p> - 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. <tt>Depends: python (>= 2.4), python (<= 2.5)</tt>. No - tools currently exist to alleviate this situation. - </p> + TODO: Currently there is no mechanism to automatically + recompile such modules when the default python version + changes. The required dependency on "<package>python + (>= <var>X</var>.<var>Y</var>), python (<< + <var>X</var>.<var>Y+1</var>)</package>" ensures the + package is upgraded, and hence recompiled, when the + default python version changes. In the future, a mechanism + may be introduced to automatically recompile such modules + when the <package>python</package> package is upgraded, + allowing such packages which support several python + versions to only depend on "<package>python (>= + <var>min.version</var>)</package>". </sect1> </sect> <sect id="version_dep_progs"> <heading>Programs Using a Particular Python Version</heading> <p> - A program which requires a specific version of Python must - begin with - <tt>#!/usr/bin/python<var>X</var>.<var>Y</var></tt> (or - <tt>#!/usr/bin/env python<var>X</var>.<var>Y</var></tt>). It + Programs which require a specific version of Python must + start with + <tt>#!/usr/bin/python<var>X</var>.<var>Y</var></tt>. They must also specify a dependency on <package>python<var>X</var>.<var>Y</var></package> and on any <package>python<var>X</var>.<var>Y</var>-foo</package> - package providing necessary modules. It should not depend on - any <package>python-foo</package> 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. <tt>Depends: python2.4-foo, python-foo (>= - 1.0)</tt>). + package providing necessary modules. They must not depend on + any <package>python-foo</package> package. + </p> + <p> + Again, if you're using <tt>#!/usr/bin/env + python<var>X</var>.<var>Y</var></tt>, please be aware that a user + might override the Debian Python package with a local version. + </p> + <p> + If the program ships private python modules, these modules + should be installed in + <tt>/usr/lib/python<var>X</var>.<var>Y</var>/site-packages/<var>module</var></tt> + (where python<var>X</var>.<var>Y</var> is the same python + version the program uses) or + <tt>/usr/lib/<var>package</var></tt>. In the latter case, + this directory should be added to <tt>sys.path</tt> at the + program startup. They must not be shipped in + <tt>/usr/lib/site-python/</tt>. The latter case is + recommended, if the private modules would pollute the name + space in <tt>sys.path</tt>. </p> <p> - The notes on installation directories and bytecompilation - for programs that support any version of Python also apply - to programs supporting only a single Python version. Modules - to be bytecompiled should use the same Python version as the - package itself. + The bytecompiled versions of the modules must not be shipped + in the package, and they should be generated as explained in + <ref id="bytecompilation">, using the same + python<var>X</var>.<var>Y</var> version as the program. </p> </sect> + </chapt> + <chapt id="embed"> <heading>Programs Embedding Python</heading> @@ -517,145 +680,33 @@ XB-Python-Version: ${python:Versions} <p> Build dependencies for Python dependent packages must be declared for every Python version that the package is built - for. The <package>python-all-dev</package> should be used when - building modules for any or all Python versions. To build for - a specific version or versions, Build-Depend on - <package>python<var>X</var>.<var>Y</var>-dev</package>. - </p> - <p> - Some applications and pure Python modules may be able to - depend only on <package>python</package> - or <package>python-all</package> and not require the -dev - packages. + for. To build for a specific version, add the versioned + dependencies; to build for the default version, add the + unversioned dependency. + + Architecture dependent packages must depend on the + <package>-dev</package> package; for architecture independent + packages, it may be sufficient to depend on the + <package>python</package> or + <package>python<var>X</var>.<var>Y</var></package> package. </p> - <p> Build-Depend on at least: <example> +Build-Depends: python1.5 +Build-Depends: python2.1 +Build-Depends: python2.2 (>= 2.2.3) Build-Depends: python2.3 (>= 2.3-1) -Build-Depends: python2.4 (>= 2.4-1) -Build-Depends: python (>= 2.3.5-7) -Build-Depends: python-all +Build-Depends: python (>= 2.3) +Build-Depends: python1.5-dev (>= 1.5.2-18.6) +Build-Depends: python1.5-distutils +Build-Depends: python2.1-dev (>= 2.1.1-1.4) +Build-Depends: python2.2-dev (>= 2.2.3) Build-Depends: python2.3-dev (>= 2.3-1) -Build-Depends: python2.4-dev (>= 2.4-1) -Build-Depends: python-dev (>= 2.3.5-7) -Build-Depends: python-all-dev +Build-Depends: python-dev (>= 2.3) </example> </p> - <p> - If you use either <package>python-support</package> or - <package>python-central</package> you must additionally - Build-Depend on those. If you are using <prgn>dh_python</prgn> - at all, you must Build-Depend on <package>python</package>, as - <package>debhelper</package> does not depend on it. - </p> - </appendix> - - <appendix id="packaging_tools"> - <heading>Packaging Tools</heading> - <p> - This section describes the various tools to help package - Python programs and modules for Debian. Although none of these - tools are mandatory, their use is strongly encouraged, as the - above policy has been designed with them in mind (and vice - versa). This appendix is just an overview. If you use these - tools, you should read their full documentation. - </p> - <sect id="pysupport"> - <heading>python-support</heading> - <p> - The python-support system provides a simple way to - bytecompile pure Python modules and manage dependencies. It - integrates with <package>debhelper</package>. When using - python-support, you should install your modules - to <file>/usr/share/python-support/<var>package</var></file> - rather than the standard Python directories. python-support - will then handle compiling the modules and making - appropriate symbolic links for installed Python versions to - find them, - substitute <tt>${python:Depends}</tt>, <tt>${python:Versions}</tt>, - and <tt>${python:Provides}</tt> in your control file, and - manage bytecompilation in your postinst/prerm. - </p> - <p> - To use it, call <prgn>dh_pysupport</prgn> - before <prgn>dh_python</prgn>, and make sure you've - installed the modules in the right place: - <example> -PREFIX := debian/python-package/usr -... -install: - ... - ./setup.py install --no-compile \ - --install-lib=$(PREFIX)/share/python-support/python-package -binary-indep: build install - ... - dh_pysupport - dh_python - ... - </example> - </p> - <p> - python-support can also manage private modules. To use this - feature, pass a list of directories to be managed by - python-support to <prgn>dh_pysupport</prgn> - and <prgn>dh_python</prgn>. python-support cannot handle - compiled extensions. - </p> - </sect> - - <sect id="pycentral"> - <heading>python-central</heading> - <p> - python-central provides another way to manage Python - modules. It integrates with <package>debhelper</package>, - but can also be used without it. When using python-central, - you should install your modules normally. It will then move - them to its private directory, and manage the same things - python-support does. - </p> - <p> - To use it, call <prgn>dh_pycentral</prgn> - before <prgn>dh_python</prgn>: - <example> -install: - ... - ./setup.py install - -binary-indep: build install - ... - dh_pycentral - dh_python - ... - </example> - </p> - <p> - python-central can handle compiled extensions for multiple - Python versions. If you want python-central to handle - private modules, you must pass the list of directories - containing them to <prgn>dh_python</prgn> (but - not <prgn>dh_pycentral</prgn>). - </p> - <p> - If python-central should not move the files to its private - directory, use<prgn>DH_PYCENTRAL=nomove dh_pycentral</prgn> - instead. - </p> - <p> - Examples for source packages using python-central are - pyenchant, python-imaging (modules and extensions), - pyparallel (modules only). - </p> - </sect> - - <sect id="cdbs"> - <heading>CDBS</heading> - <p> - FIXME: Someone familiar with CDBS should write this part. - </p> - </sect> - </appendix> <appendix id="upgrade"> @@ -668,11 +719,6 @@ binary-indep: build install </p> <p> <enumlist> - <item> - <p> - Have a long and heated discussion. - </p> - </item> <item> <p> The Debian Python maintainer decides for the new default Debian @@ -687,12 +733,43 @@ binary-indep: build install the new <package>python<var>X</var>.<var>Y</var></package>, <package>python<var>X</var>.<var>Y</var>-dev</package> and so on. </p> + <p> + These new packages will make uninstallable all python packages + depending on the previous <package>python</package> with a + dependency requiring version less than <var>X</var>.<var>Y</var>. + </p> + </item> + <item> + <p> + From this point, all these python modules/packages which are + uninstallable have to be rebuilt against the new python version, + fixing dependencies and build-dependencies. + </p> + <p> + NMUs are allowed after notifying the package maintainer + to have all these packages rebuilt in a reasonable + timeline. + </p> + </item> + <item> + <p> + File bug report against packages and/or make NMU's for packages + that are not adapted by their maintainer. + </p> + </item> + <item> + <p> + If a package doesn't work with the new python version, + make it use the older version as described in <ref + id="version_dep_progs">. + </p> </item> <item> <p> - The release team schedules rebuilds for packages that - may need it. Packages that require manual work get - updated and uploaded. + When all packages are updated (or removed), the new + <package>python</package> packages can migrate to + <tt>testing</tt> together with all packages depending on + it. </p> </item> </enumlist> diff --git a/debian/python.preinst b/debian/python.preinst index b00321b..b76ec49 100644 --- a/debian/python.preinst +++ b/debian/python.preinst @@ -2,11 +2,4 @@ [ -L /usr/share/doc/python/html ] || rm -rf /usr/share/doc/python/html -# remove the python alternatives before installing our own python link - -update-alternatives --auto /usr/bin/python >/dev/null 2>&1 || true -update-alternatives --remove python /usr/bin/python1.5 || true -update-alternatives --remove python /usr/bin/python2.1 || true -update-alternatives --remove python /usr/bin/python2.2 || true - #DEBHELPER# diff --git a/debian/pyversions b/debian/pyversions new file mode 100755 index 0000000..d9097b1 --- /dev/null +++ b/debian/pyversions @@ -0,0 +1,6 @@ +#! /usr/bin/python + +import sys +sys.path[0:0] = ['/usr/share/python'] +import pyversions +pyversions.main() diff --git a/debian/pyversions.1 b/debian/pyversions.1 index 9d911ee..9ca8d02 100644 --- a/debian/pyversions.1 +++ b/debian/pyversions.1 @@ -19,15 +19,12 @@ Show the default python version. .I -s, --supported Show the supported python versions. .TP -.I -r, --requested [<version string> | <control file>] -Reads the value of the +.I -r, --requested <version string> | <control file> +Reads the .B XS-Python-Version -field in the source section of a control file and shows all matching -python versions. The parameter is interpreted as a version string, if -it is not the name of a file. If the XS-Python-Version field is -missing, get the version information from debian/pyversions. -Without any parameter, it will fall back to list the supported Python -versions after checking debian/control and debian/pyversions. +value in the source section of a control file and shows all +matching python versions. The parameter is interpreted as +a version string, if it is not the name of a file. .TP .I -i, --installed Show the installed supported python versions. diff --git a/debian/pyversions.py b/debian/pyversions.py index e6e3643..4817c71 100644 --- a/debian/pyversions.py +++ b/debian/pyversions.py @@ -50,9 +50,9 @@ def supported_versions(version_only=False): global _supported_versions if not _supported_versions: if os.path.exists('/usr/share/python/debian_defaults'): - from ConfigParser import SafeConfigParser - config = SafeConfigParser() - config.readfp(file('/usr/share/python/debian_defaults')) + import ConfigParser + config = ConfigParser.SafeConfigParser() + config.read('/usr/share/python/debian_defaults') value = config.get('DEFAULT', 'supported-versions') _supported_versions = [s.strip() for s in value.split(',')] else: @@ -92,10 +92,11 @@ def requested_versions(vstring, version_only=False): vinfo = parse_versions(vstring) supported = supported_versions(version_only=True) if len(vinfo) == 1: + vkey = vinfo[vinfo.keys()[0]] if 'all' in vinfo: versions = supported elif 'current' in vinfo: - versions = [default_version(version_only=True)] + versions = [default_version()] else: versions = vinfo['versions'].intersection(supported) elif 'all' in vinfo and 'current' in vinfo: @@ -118,21 +119,14 @@ def requested_versions(vstring, version_only=False): def installed_versions(version_only=False): import glob - supported = supported_versions() versions = [os.path.basename(s) - for s in glob.glob('/usr/bin/python[0-9].[0-9]') - if os.path.basename(s) in supported] + for s in glob.glob('/usr/bin/python[0-9].[0-9]')] versions.sort() if version_only: return [v[6:] for v in versions] else: return versions -class ControlFileValueError(ValueError): - pass -class MissingVersionValueError(ValueError): - pass - def extract_pyversion_attribute(fn, pkg): """read the debian/control file, extract the XS-Python-Version field; check that XB-Python-Version exists for the package.""" @@ -143,13 +137,11 @@ def extract_pyversion_attribute(fn, pkg): for line in file(fn): line = line.strip() if line == '': - if pkg == 'Source': - break section = None elif line.startswith('Source:'): section = 'Source' elif line.startswith('Package: ' + pkg): - section = pkg + section = self.name elif line.startswith('XS-Python-Version:'): if section != 'Source': raise ValueError, \ @@ -158,55 +150,15 @@ def extract_pyversion_attribute(fn, pkg): elif line.startswith('XB-Python-Version:'): if section == pkg: version = line.split(':', 1)[1].strip() - if section == None: - raise ControlFileValueError, 'not a control file' if pkg == 'Source': if sversion == None: - raise MissingVersionValueError, \ - 'missing XS-Python-Version in control file' + raise ValueError, 'missing XS-Python-Version in control file' return sversion if version == None: - raise MissingVersionValueError, \ + raise ValueError, \ 'missing XB-Python-Version for package `%s' % pkg return version -# compatibility functions to parse debian/pyversions - -def version_cmp(ver1,ver2): - v1=[int(i) for i in ver1.split('.')] - v2=[int(i) for i in ver2.split('.')] - return cmp(v1,v2) - -def requested_versions_bis(vstring, version_only=False): - versions = [] - py_supported_short = supported_versions(version_only=True) - for item in vstring.split(','): - v=item.split('-') - if len(v)>1: - if not v[0]: - v[0] = py_supported_short[0] - if not v[1]: - v[1] = py_supported_short[-1] - for ver in py_supported_short: - try: - if version_cmp(ver,v[0]) >= 0 \ - and version_cmp(ver,v[1]) <= 0: - versions.append(ver) - except ValueError: - pass - else: - if v[0] in py_supported_short: - versions.append(v[0]) - versions.sort(version_cmp) - if not versions: - raise ValueError, 'empty set of versions' - if not version_only: - versions=['python'+i for i in versions] - return versions - -def extract_pyversion_attribute_bis(fn): - vstring = file(fn).readline().rstrip('\n') - return vstring def main(): from optparse import OptionParser @@ -220,7 +172,7 @@ def main(): action='store_true', dest='supported') parser.add_option('-r', '--requested', help='print the python versions requested by a build; the argument is either the name of a control file or the value of the XS-Python-Version attribute', - action='store_true', dest='requested') + action='store', dest='versions') parser.add_option('-i', '--installed', help='print the installed supported python versions', action='store_true', dest='installed') @@ -230,46 +182,24 @@ def main(): opts, args = parser.parse_args() program = os.path.basename(sys.argv[0]) - if opts.default and len(args) == 0: + if opts.default: print default_version(opts.version_only) - elif opts.supported and len(args) == 0: + elif opts.supported: print ' '.join(supported_versions(opts.version_only)) - elif opts.installed and len(args) == 0: + elif opts.installed: print ' '.join(installed_versions(opts.version_only)) - elif opts.requested and len(args) <= 1: - if len(args) == 0: - versions = 'debian/control' - else: - versions = args[0] + elif opts.versions: try: - if os.path.isfile(versions): - fn = versions - try: - vstring = extract_pyversion_attribute(fn, 'Source') - vs = requested_versions(vstring, opts.version_only) - except ControlFileValueError: - sys.stderr.write("%s: not a control file: %s, " \ - % (program, fn)) - sys.exit(1) - except MissingVersionValueError: - fn = os.path.join(os.path.dirname(fn), 'pyversions') - sys.stderr.write("%s: missing XS-Python-Version in control file, fall back to %s\n" \ - % (program, fn)) - try: - vstring = extract_pyversion_attribute_bis(fn) - vs = requested_versions_bis(vstring, opts.version_only) - except IOError: - sys.stderr.write("%s: missing debian/pyversions file, fall back to supported versions\n" \ - % program) - vs = supported_versions(opts.version_only) + if os.path.isfile(opts.versions): + vs = extract_pyversion_attribute(opts.versions, 'Source') else: - vs = requested_versions(versions, opts.version_only) - print ' '.join(vs) + vs = opts.versions + print ' '.join(requested_versions(vs, opts.version_only)) except ValueError, msg: - sys.stderr.write("%s: %s\n" % (program, msg)) + print "%s: %s" % (program, msg) sys.exit(1) else: - sys.stderr.write("usage: %s %s\n" % (program, usage)) + print "usage: %s %s" % (program, usage) sys.exit(1) if __name__ == '__main__': diff --git a/debian/rules b/debian/rules index d5a77f4..68e31ab 100755 --- a/debian/rules +++ b/debian/rules @@ -8,13 +8,14 @@ export SHELL = /bin/bash DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) -export VER=2.3 -export NVER=2.4 -export PVER=python2.3 -export PRIORITY=$(shell echo $(VER) | tr -d '.')0 +export VER=2.4 +export NVER=2.5 +export PVER=python2.4 + +VERSIONS = 2.3 2.4 PREVVER := $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog) -PREVVER := 2.3.5-14 +PREVVER := 2.4.3 PWD := $(shell pwd) @@ -48,7 +49,6 @@ control-file: -e "s/@NVER@/$(NVER)/g" \ -e "s/@VER@/$(VER)/g" \ -e "s/@PREVVER@/$(PREVVER)/g" \ - -e "s/@PRIO@/$(PY_PRIO)/g" \ <debian/control.in >debian/control.tmp [ -e debian/control ] \ && cmp -s debian/control debian/control.tmp \ @@ -71,7 +71,7 @@ get-faq: ) >> faq/FAQ.ht rm -f faq/index.ht -clean: +clean: control-file dh_testdir dh_testroot rm -f stamp-* @@ -82,19 +82,18 @@ clean: rm -f faq/*.h2 faq/*.html for f in debian/*.in; do \ - f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/VER/$(VER)/g;s,\.in$$,,"`; \ if [ $$f2 != debian/control ]; then \ rm -f $$f2; \ fi; \ done - rm -f debian/*.py[co] dh_clean stamp-control: : # We have to prepare the various control files for f in debian/*.in; do \ - f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/VER/$(VER)/g;s,\.in$$,,"`; \ if [ $$f2 != debian/control ]; then \ sed -e "s/@PVER@/$(PVER)/g;s/@VER@/$(VER)/g" \ -e "s/@PRIORITY@/$(PRIORITY)/g" \ @@ -130,15 +129,33 @@ binary-indep: build install stamp-doc dh_testroot -i : # provide the python and python.1 defaults + mkdir -p debian/python-minimal/usr/bin + ln -sf python$(VER) debian/python-minimal/usr/bin/python + mkdir -p debian/python-minimal/usr/share/man/man1 + ln -sf python$(VER).1.gz \ + debian/python-minimal/usr/share/man/man1/python.1.gz + + : # + mkdir -p debian/python-minimal/usr/share/python + cp -p debian/debian_defaults \ + debian/python-minimal/usr/share/python/ + + cp -p debian/pyversions.py \ + debian/python-minimal/usr/share/python/ + install -m 755 debian/pyversions \ + debian/python-minimal/usr/bin/ + cp -p debian/pyversions.1 \ + debian/python-minimal/usr/share/man/man1/ + +# mkdir debian/python-minimal/usr/share/python-central +# cp -p debian/python.pycentral debian/python-minimal/usr/share/python-central/ + mkdir -p debian/python/usr/bin - ln -sf python$(VER) debian/python/usr/bin/python ln -sf pydoc$(VER) debian/python/usr/bin/pydoc ln -sf pygettext$(VER) debian/python/usr/bin/pygettext ln -sf pdb$(VER) debian/python/usr/bin/pdb mkdir -p debian/python/usr/share/man/man1 - ln -sf python$(VER).1.gz \ - debian/python/usr/share/man/man1/python.1.gz ln -sf pydoc$(VER).1.gz \ debian/python/usr/share/man/man1/pydoc.1.gz ln -sf pygettext$(VER).1.gz \ @@ -146,17 +163,6 @@ binary-indep: build install stamp-doc ln -sf pdb$(VER).1.gz \ debian/python/usr/share/man/man1/pdb.1.gz - : # - mkdir -p debian/python/usr/share/python - cp -p debian/debian_defaults \ - debian/python/usr/share/python/ - - install -m 755 debian/pyversions.py \ - debian/python/usr/share/python/ - install -m 644 debian/pyversions.1 \ - debian/python/usr/share/man/man1/ - dh_link -ppython /usr/share/python/pyversions.py /usr/bin/pyversions - mkdir -p debian/python/usr/share/doc/python cp -a debian/python-policy.{html,sgml,txt} \ debian/python/usr/share/doc/python/ @@ -200,8 +206,13 @@ endif dh_installdocs -i $(NOPKGS) --all debian/README.Debian dh_installmenu -i $(NOPKGS) dh_installchangelogs -i $(NOPKGS) -# rm -rf debian/python-all-dev/usr/share/doc/python-all-dev -# ln -sf python$(VER)-all debian/python-all-dev/usr/share/doc/python-all-dev + + for p in all all-dev dbg dev examples idle; do \ + [ $$p = idle ] || p=python-$$p; \ + rm -rf debian/$$p/usr/share/doc/$$p; \ + ln -sf python debian/$$p/usr/share/doc/$$p; \ + done + dh_compress -i $(NOPKGS) dh_fixperms -i $(NOPKGS) dh_installdeb -i $(NOPKGS) -- GitLab