From 0f061cf85aef32cc9b17c779402d5697461a7db5 Mon Sep 17 00:00:00 2001 From: Matthias Klose <doko@timbuktu> Date: Mon, 17 May 2010 12:59:38 +0200 Subject: [PATCH] package version python-defaults-2.5.4-1 --- debian/changelog | 12 ++++++- debian/compat | 2 +- debian/control | 16 ++++----- debian/control.in | 4 +-- debian/python.mk | 36 +++++++++++++++++++ debian/pyversions.py | 82 +++++++++++++++++++++++++++++++++++--------- debian/rules | 6 +++- 7 files changed, 128 insertions(+), 30 deletions(-) create mode 100644 debian/python.mk diff --git a/debian/changelog b/debian/changelog index fb028e3..a9f8db2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +python-defaults (2.5.4-1) unstable; urgency=medium + + * Depend on python2.5-2.5.4. + * python: Install /usr/share/python/python.mk, helper functions for + getting the python library dir and install args for distutils installs. + * Accept initial blank line in debian/control when parsing version + information. + + -- Matthias Klose <doko@debian.org> Wed, 25 Feb 2009 02:19:09 +0000 + python-defaults (2.5.2-3) unstable; urgency=low * python: Provide python-ctypes and python-wsgiref. @@ -7,7 +17,7 @@ python-defaults (2.5.2-3) unstable; urgency=low python-defaults (2.5.2-2) unstable; urgency=low * python: Provide python-plistlib. - * python-minimal: Provide python (suggested by Neil McGovern). + * python-minimal: Recommend python (suggested by Neil McGovern). -- Matthias Klose <doko@debian.org> Sat, 26 Jul 2008 02:37:00 +0200 diff --git a/debian/compat b/debian/compat index b8626c4..7ed6ff8 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -4 +5 diff --git a/debian/control b/debian/control index 6ec6630..aa704d6 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,13 @@ 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 (>= 0.4-3), python -Standards-Version: 3.7.2 +Build-Depends-Indep: debhelper (>= 5), libhtml-tree-perl, debiandoc-sgml, python-docutils (>= 0.4-3), python +Standards-Version: 3.8.0 Package: python Architecture: all Priority: standard -Depends: python2.5 (>= 2.5.2), python-minimal (= ${Source-Version}) +Depends: python2.5 (>= 2.5.4), python-minimal (= ${Source-Version}) Conflicts: python2.3 (<< 2.3.5-14), python2.1 (<= 2.1.2), python-xmlbase, python-csv, python-bz2, python-base, python-central (<< 0.5.5) Replaces: python2.3 (<= 2.3.2-6), python-xmlbase, python-base Provides: python-email, python-xmlbase, python-plistlib, python-ctypes, python-wsgiref @@ -24,7 +24,7 @@ Description: An interactive high-level object-oriented language (default version Package: python-minimal Architecture: all Priority: standard -Depends: python2.5-minimal (>= 2.5.2), dpkg (>= 1.13.20) +Depends: python2.5-minimal (>= 2.5.4), dpkg (>= 1.13.20) Conflicts: python (<= 2.4-1), python-central (<< 0.5.5) Replaces: python (<= 2.4-1) Recommends: python @@ -36,7 +36,7 @@ Description: A minimal subset of the Python language (default version) Package: python-examples Architecture: all -Depends: python (= ${Source-Version}), python2.5-examples (>= 2.5.2) +Depends: python (= ${Source-Version}), python2.5-examples (>= 2.5.4) Description: Examples for the Python language (default version) Examples, Demos and Tools for Python. These are files included in the upstream Python distribution. @@ -46,7 +46,7 @@ Description: Examples for the Python language (default version) Package: python-dev Architecture: all -Depends: python (= ${Source-Version}), python2.5-dev (>= 2.5.2) +Depends: python (= ${Source-Version}), python2.5-dev (>= 2.5.4) 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 @@ -72,7 +72,7 @@ Description: An IDE for Python using Tkinter (default version) Package: python-doc Section: doc Architecture: all -Depends: python2.5-doc (>= 2.5.2) +Depends: python2.5-doc (>= 2.5.4) Suggests: python Conflicts: python-doc-info, python (<< 2.3.5) Replaces: python-doc-info, python (<< 2.3.5) @@ -97,7 +97,7 @@ Description: Documentation for the high-level object-oriented language Python Package: python-dbg Architecture: all Priority: extra -Depends: python (= ${Source-Version}), python2.5-dbg (>= 2.5.2) +Depends: python (= ${Source-Version}), python2.5-dbg (>= 2.5.4) Provides: python-gdbm-dbg, python-tk-dbg Description: Debug Build of the Python Interpreter (version 2.5) Python interpreter configured with --pydebug. Dynamically loaded modules are diff --git a/debian/control.in b/debian/control.in index 7c38659..4387732 100644 --- a/debian/control.in +++ b/debian/control.in @@ -2,8 +2,8 @@ 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 (>= 0.4-3), python -Standards-Version: 3.7.2 +Build-Depends-Indep: debhelper (>= 5), libhtml-tree-perl, debiandoc-sgml, python-docutils (>= 0.4-3), python +Standards-Version: 3.8.0 Package: python Architecture: all diff --git a/debian/python.mk b/debian/python.mk new file mode 100644 index 0000000..ea58b9c --- /dev/null +++ b/debian/python.mk @@ -0,0 +1,36 @@ +# some macros useful for packaging python packages + +# to include it unconditionally: +# include /usr/share/python/python.mk +# +# to include it conditionally, and have the packaging working with earlier releases +# and backports: +# -include /usr/share/python/python.mk +# ifeq (,$(py_sitename)) +# py_sitename = site-packages +# py_libdir = /usr/lib/python$(subst python,,$(1))/site-packages +# py_sitename_sh = $(py_sitename) +# py_libdir_sh = $(py_libdir) +# endif + +# py_sitename: name of the site-packages/dist-packages directory depending +# on the python version. Call as: $(call py_sitename, <python version>). +# Don't use this in shell snippets inside loops. + +py_sitename = $(if $(filter $(subst python,,$(1)), 2.3 2.4 2.5),site,dist)-packages + +# py_libdir: absolute path to the default python library for third party +# stuff. Call as: $(call py_libdir, <python version>). +# Don't use this in shell snippets inside loops. + +py_libdir = /usr/lib/python$(subst python,,$(1))/$(py_sitename) + + +# The same macros for use in shell snippets + +py_sitename_sh = $$(basename $$(python$(subst python,,$(1)) -c 'from distutils import sysconfig; print sysconfig.get_python_lib()')) + +py_libdir_sh = $$(python$(subst python,,$(1)) -c 'from distutils import sysconfig; print sysconfig.get_python_lib()') + +# Arguments to pass to setup.py install +py_setup_install_args = --install-layout=deb diff --git a/debian/pyversions.py b/debian/pyversions.py index 77c1f1a..db8d755 100644 --- a/debian/pyversions.py +++ b/debian/pyversions.py @@ -25,7 +25,7 @@ def read_default(name=None): return value return None -def parse_versions(vstring): +def parse_versions(vstring, add_exact=False): import operator operators = { None: operator.eq, '=': operator.eq, '>=': operator.ge, '<=': operator.le, @@ -33,7 +33,8 @@ def parse_versions(vstring): } vinfo = {} exact_versions = set([]) - version_range = set(supported_versions(version_only=True)) + version_range = set(supported_versions(version_only=True) + + old_versions(version_only=True)) relop_seen = False for field in vstring.split(','): field = field.strip() @@ -56,10 +57,19 @@ def parse_versions(vstring): version_range = [av for av in version_range if filtop(av ,v)] except Exception: raise ValueError, 'error parsing Python-Version attribute' - if 'versions' in vinfo: - vinfo['versions'] = exact_versions - if relop_seen: - vinfo['versions'] = exact_versions.union(version_range) + if add_exact: + if exact_versions: + vinfo['vexact'] = exact_versions + if 'versions' in vinfo: + if relop_seen: + vinfo['versions'] = set(version_range) + else: + del vinfo['versions'] + else: + if 'versions' in vinfo: + vinfo['versions'] = exact_versions + if relop_seen: + vinfo['versions'] = exact_versions.union(version_range) return vinfo _old_versions = None @@ -112,8 +122,13 @@ def supported_versions(version_only=False): if line.startswith('Depends:'): depends = line.split(':', 1)[1].strip().split(',') fd.close() - depends = [re.sub(r'\s*(\S+)[ (]?.*', r'\1', s) for s in depends] - _supported_versions = depends + if depends: + depends = [re.sub(r'\s*(\S+)[ (]?.*', r'\1', s) for s in depends] + _supported_versions = depends + if not _supported_versions: + # last resort: python-minimal not installed, apt-cache + # not available, hard code the value, #394084 + _supported_versions = ['python2.4', 'python2.5'] if version_only: return [v[6:] for v in _supported_versions] else: @@ -123,12 +138,30 @@ _default_version = None def default_version(version_only=False): global _default_version if not _default_version: - _default_version = link = os.readlink('/usr/bin/python') - # consistency check - debian_default = read_default('default-version') - if not _default_version in (debian_default, os.path.join('/usr/bin', debian_default)): - raise ValueError, "the symlink /usr/bin/python does not point to the python default version. It must be reset to point to %s" % debian_default - _default_version = debian_default + try: + _default_version = link = os.readlink('/usr/bin/python') + except OSError: + _default_version = None + try: + cmd = ['/usr/bin/python', '-c', 'import sys; print sys.version[:3]'] + import subprocess + p = subprocess.Popen(cmd, bufsize=1, + shell=False, stdout=subprocess.PIPE) + fd = p.stdout + except ImportError: + fd = os.popen("/usr/bin/python -c 'import sys; print sys.version[:3]'") + line = fd.readline().strip() + fd.close() + if re.match(r'\d\.\d$', line): + _default_version = 'python' + line + # consistency check + try: + debian_default = read_default('default-version') + except ValueError: + debian_default = "python2.5" + if not _default_version in (debian_default, os.path.join('/usr/bin', debian_default)): + raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default + _default_version = debian_default if version_only: return _default_version[6:] else: @@ -136,28 +169,41 @@ def default_version(version_only=False): def requested_versions(vstring, version_only=False): versions = None - vinfo = parse_versions(vstring) + vinfo = parse_versions(vstring, add_exact=True) supported = supported_versions(version_only=True) if len(vinfo) == 1: if 'all' in vinfo: versions = supported elif 'current' in vinfo: versions = [default_version(version_only=True)] + elif 'vexact' in vinfo: + versions = vinfo['vexact'] else: versions = vinfo['versions'].intersection(supported) elif 'all' in vinfo and 'current' in vinfo: raise ValueError, "both `current' and `all' in version string" elif 'all' in vinfo: - versions = versions = vinfo['versions'].intersection(supported) + if 'versions' in vinfo: + versions = vinfo['versions'].intersection(supported) + else: + versions = set(supported) + if 'vexact' in vinfo: + versions.update(vinfo['vexact']) elif 'current' in vinfo: current = default_version(version_only=True) if not current in vinfo['versions']: raise ValueError, "`current' version not in supported versions" versions = [current] + elif 'versions' in vinfo or 'vexact' in vinfo: + versions = set() + if 'versions' in vinfo: + versions = vinfo['versions'].intersection(supported) + if 'vexact' in vinfo: + versions.update(vinfo['vexact']) else: raise ValueError, 'error in version string' if not versions: - raise ValueError, 'empty set of versions' + raise PyCentralEmptyValueError, 'empty set of versions' if version_only: return versions else: @@ -190,6 +236,8 @@ def extract_pyversion_attribute(fn, pkg): for line in file(fn): line = line.strip() if line == '': + if section == None: + continue if pkg == 'Source': break section = None diff --git a/debian/rules b/debian/rules index 42c3912..4e07d18 100755 --- a/debian/rules +++ b/debian/rules @@ -20,7 +20,7 @@ export NVER=2.6 export PVER=python2.5 PREVVER := $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog) -PREVVER := 2.5.2 +PREVVER := 2.5.4 PWD := $(shell pwd) @@ -170,6 +170,10 @@ binary-indep: build install stamp-doc ln -sf pygettext$(VER) debian/python/usr/bin/pygettext ln -sf pdb$(VER) debian/python/usr/bin/pdb + mkdir -p debian/python/usr/share/python + install -m 644 debian/python.mk \ + debian/python/usr/share/python/ + mkdir -p debian/python/usr/share/man/man1 ln -sf pydoc$(VER).1.gz \ debian/python/usr/share/man/man1/pydoc.1.gz -- GitLab