This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dh-python.

commit c977a6a5ac265bdcccaa95bae3c302ef7a57b3fe
Author: Piotr Ożarowski <pi...@debian.org>
Date:   Sat Jun 29 15:49:10 2013 +0200

    add Interpreter.old_sitedirs
---
 dh_python2              | 23 +++++------------------
 dh_python3              | 21 ++++-----------------
 dhpython/__init__.py    | 21 +++++++++++++++++++++
 dhpython/interpreter.py | 31 ++++++++++++++++++++++++++++++-
 4 files changed, 60 insertions(+), 36 deletions(-)

diff --git a/dh_python2 b/dh_python2
index 63ce3b3..25ab2cc 100755
--- a/dh_python2
+++ b/dh_python2
@@ -69,22 +69,13 @@ def fix_locations(package):
     for version in SUPPORTED:
         interpreter.version = version
 
-        to_check = [i % version for i in (
-                    'usr/local/lib/python%s/site-packages',
-                    'usr/local/lib/python%s/dist-packages',
-                    'var/lib/python-support/python%s',
-                    'usr/lib/pymodules/python%s')]
-        if version >= '2.6':
-            to_check.append("usr/lib/python%s/site-packages" % version)
         dstdir = interpreter.sitedir(package)
-
-        for location in to_check:
-            srcdir = "debian/%s/%s" % (package, location)
+        for srcdir in interpreter.old_sitedirs(package):
             if isdir(srcdir):
                 if version in found_versions:
                     log.error('files for version %s '
                               'found in two locations:\n %s\n %s',
-                              version, location, found_versions[version])
+                              version, srcdir, found_versions[version])
                     exit(2)
                 log.info('Python %s should install files in %s. '
                          'Did you forget "--install-layout=deb"?',
@@ -94,15 +85,11 @@ def fix_locations(package):
                 # TODO: what about relative symlinks?
                 log.debug('moving files from %s to %s', srcdir, dstdir)
                 os.renames(srcdir, dstdir)
-                found_versions[version] = location
+                found_versions[version] = srcdir
 
         # do the same with debug locations
-        dbg_to_check = ['usr/lib/debug/%s' % i for i in to_check]
-        dbg_to_check.append("usr/lib/debug/usr/lib/pyshared/python%s" % 
version)
-        dstdir = interpreter.sitedir(gdb=True, package=package)
-
-        for location in dbg_to_check:
-            srcdir = "debian/%s/%s" % (package, location)
+        dstdir = interpreter.sitedir(package, gdb=True)
+        for srcdir in interpreter.old_sitedirs(package, gdb=True):
             if isdir(srcdir):
                 if not isdir(dstdir):
                     os.makedirs(dstdir)
diff --git a/dh_python3 b/dh_python3
index 87cbc7c..0d86a26 100755
--- a/dh_python3
+++ b/dh_python3
@@ -56,17 +56,8 @@ def fix_locations(package):
     for version in SUPPORTED:
         interpreter.version = version
 
-        to_check = [i % version for i in (
-                    'usr/local/lib/python%s/site-packages',
-                    'usr/local/lib/python%s/dist-packages',
-                    'usr/lib/python%s/site-packages',
-                    'usr/lib/python%s/dist-packages',
-                    'var/lib/python-support/python%s',
-                    'usr/lib/pymodules/python%s')]
-        dstdir = interpreter.sitedir(package=package)
-
-        for location in to_check:
-            srcdir = "debian/%s/%s" % (package, location)
+        dstdir = interpreter.sitedir(package)
+        for srcdir in interpreter.old_sitedirs(package):
             if isdir(srcdir):
                 # TODO: what about relative symlinks?
                 log.debug('moving files from %s to %s', srcdir, dstdir)
@@ -76,12 +67,8 @@ def fix_locations(package):
                     os.rmdir(parent_dir)
 
         # do the same with debug locations
-        dbg_to_check = ['usr/lib/debug/%s' % i for i in to_check]
-        dbg_to_check.append("usr/lib/debug/usr/lib/pyshared/python%s" % 
version)
-        dstdir = interpreter.sitedir(gdb=True, package=package)
-
-        for location in dbg_to_check:
-            srcdir = "debian/%s/%s" % (package, location)
+        dstdir = interpreter.sitedir(package, gdb=True)
+        for srcdir in interpreter.old_sitedirs(package, gdb=True):
             if isdir(srcdir):
                 log.debug('moving files from %s to %s', srcdir, dstdir)
                 share_files(srcdir, dstdir, package.endswith('-dbg'))
diff --git a/dhpython/__init__.py b/dhpython/__init__.py
index f91a34b..b213956 100644
--- a/dhpython/__init__.py
+++ b/dhpython/__init__.py
@@ -27,6 +27,27 @@ MINPYCDEP = {'cpython2': 'python (>= 2.6.6-3)',
              'cpython3': 'python3 (>= 3.2.3-3~)',
              'pypy': 'pypy'}
 
+# Interpreter site-directories
+OLD_SITE_DIRS = {
+    'cpython2': [
+        '/usr/local/lib/python{}/site-packages',
+        '/usr/local/lib/python{}/dist-packages',
+        '/var/lib/python-support/python{}',
+        '/usr/lib/pymodules/python{}',
+        lambda version: '/usr/lib/python{}/site-packages'.format(version)
+                        if version >= '2.6' else None],
+    'cpython3': [
+        '/usr/local/lib/python{}/site-packages',
+        '/usr/local/lib/python{}/dist-packages',
+        '/usr/lib/python{}/site-packages',
+        '/usr/lib/python{}/dist-packages',
+        '/var/lib/python-support/python{}',
+        '/usr/lib/pymodules/python{}'],
+    'pypy': [
+        '/usr/local/lib/pypy/site-packages',
+        '/usr/local/lib/pypy/dist-packages',
+        '/usr/lib/pypy/site-packages']}
+
 # PyDist related
 PYDIST_DIRS = {
     'cpython2': '/usr/share/python/dist/',
diff --git a/dhpython/interpreter.py b/dhpython/interpreter.py
index 31c6f30..5b5785a 100644
--- a/dhpython/interpreter.py
+++ b/dhpython/interpreter.py
@@ -22,6 +22,7 @@ import logging
 import os
 import re
 from os.path import join, split
+from dhpython import OLD_SITE_DIRS
 
 SHEBANG_RE = re.compile(r'''
     (?:\#!\s*){0,1}  # shebang prefix
@@ -212,7 +213,10 @@ class Interpreter:
         >>> i.sitedir(version=Version('3.2'))
         '/usr/lib/python3/dist-packages/'
         """
-        version = Version(version or self.version)
+        try:
+            version = Version(version or self.version)
+        except Exception as err:
+            raise ValueError("cannot find valid version: %s" % err)
         if self.impl == 'pypy':
             path = '/usr/lib/pypy/dist-packages/'
         elif version << Version('2.6'):
@@ -229,6 +233,31 @@ class Interpreter:
 
         return path
 
+    def old_sitedirs(self, package=None, version=None, gdb=False):
+        """Return deprecated paths to site-packages directories."""
+        try:
+            version = Version(version or self.version)
+        except Exception as err:
+            raise ValueError("cannot find valid version: %s" % err)
+        result = []
+        for item in OLD_SITE_DIRS.get(self.impl, []):
+            if isinstance(item, str):
+                result.append(item.format(version))
+            else:
+                res = item(version)
+                if res is not None:
+                    result.append(res)
+
+        if gdb:
+            result = ['/usr/lib/debug{}'.format(i) for i in result]
+            if self.impl.startswith('cpython'):
+                
result.append('/usr/lib/debug/usr/lib/pyshared/python{}'.format(version))
+        if package:
+            result = ['debian/{}{}'.format(package, i) for i in result]
+
+        return result
+
+
     def cache_file(self, fpath, version=None):
         """Given path to a .py file, return path to its .pyc/.pyo file.
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/reproducible/dh-python.git

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to