[Reproducible-builds] [dh-python] 12/183: move interpreter implementation specific definitions to __init__.py

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Sep 19 15:30:13 UTC 2014


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 5f0d04579b0bdd907b1b836fd2966c92d27c3f03
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Sat Jun 29 14:48:30 2013 +0200

    move interpreter implementation specific definitions to __init__.py
---
 dhpython/__init__.py  | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 dhpython/debhelper.py | 24 +------------------
 dhpython/depends.py   |  7 +-----
 dhpython/pydist.py    | 24 ++++---------------
 4 files changed, 73 insertions(+), 48 deletions(-)

diff --git a/dhpython/__init__.py b/dhpython/__init__.py
index 584d9d5..f91a34b 100644
--- a/dhpython/__init__.py
+++ b/dhpython/__init__.py
@@ -1,3 +1,69 @@
+# Copyright © 2010-2013 Piotr Ożarowski <piotr at debian.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
 PKG_PREFIX_MAP = {'cpython2': 'python',
                   'cpython3': 'python3',
                   'pypy': 'pypy'}
+
+# minimum version required for py3compile/py3clean:
+MINPYCDEP = {'cpython2': 'python (>= 2.6.6-3)',
+             'cpython3': 'python3 (>= 3.2.3-3~)',
+             'pypy': 'pypy'}
+
+# PyDist related
+PYDIST_DIRS = {
+    'cpython2': '/usr/share/python/dist/',
+    'cpython3': '/usr/share/python3/dist/',
+    'pypy': '/usr/share/pypy/dist/'}
+
+PYDIST_OVERRIDES_FNAMES = {
+    'cpython2': 'debian/pydist-overrides',
+    'cpython3': 'debian/py3dist-overrides',
+    'pypy': 'debian/pypydist-overrides'}
+
+PYDIST_DPKG_SEARCH_TPLS = {
+    'cpython2': "*/%s-?*\.egg-info | grep '/python2\../\|/pyshared/'",
+    'cpython3': '*python3/*/{}-?*\.egg-info',
+    'pypy': '*pypy/*/{}-?\.egg-info'}
+
+# DebHelper related
+PKG_NAME_TPLS = {
+    'cpython2': ('python-', 'python2.'),
+    'cpython3': ('python3-', 'python3.'),
+    'pypy': ('pypy-',)
+}
+RT_LOCATIONS = {
+    'cpython2': '/usr/share/python/runtime.d/',
+    'cpython3': '/usr/share/python3/runtime.d/',
+    'pypy': '/usr/share/pypy/runtime.d/',
+}
+RT_TPLS = {
+    'cpython2': '''
+if [ "$1" = rtupdate ]; then
+\tpyclean {pkg_arg} {dname}
+\tpycompile {pkg_arg} {args} {dname}
+fi''',
+    'cpython3': '''
+if [ "$1" = rtupdate ]; then
+\tpy3clean {pkg_arg} {dname}
+\tpy3compile {pkg_arg} {args} {dname}
+fi''',
+    'pypy': ''
+}
diff --git a/dhpython/debhelper.py b/dhpython/debhelper.py
index ad80455..b65407d 100644
--- a/dhpython/debhelper.py
+++ b/dhpython/debhelper.py
@@ -21,31 +21,9 @@
 import logging
 from os import makedirs, chmod
 from os.path import exists, join, dirname
+from dhpython import PKG_NAME_TPLS, RT_LOCATIONS, RT_TPLS
 
 log = logging.getLogger(__name__)
-PKG_NAME_TPLS = {
-    'cpython2': ('python-', 'python2.'),
-    'cpython3': ('python3-', 'python3.'),
-    'pypy': ('pypy-',)
-}
-RT_LOCATIONS = {
-    'cpython2': '/usr/share/python/runtime.d/',
-    'cpython3': '/usr/share/python3/runtime.d/',
-    'pypy': '/usr/share/pypy/runtime.d/',
-}
-RT_TPLS = {
-    'cpython2': '''
-if [ "$1" = rtupdate ]; then
-\tpyclean {pkg_arg} {dname}
-\tpycompile {pkg_arg} {args} {dname}
-fi''',
-    'cpython3': '''
-if [ "$1" = rtupdate ]; then
-\tpy3clean {pkg_arg} {dname}
-\tpy3compile {pkg_arg} {args} {dname}
-fi''',
-    'pypy': ''
-}
 
 
 class DebHelper:
diff --git a/dhpython/depends.py b/dhpython/depends.py
index 08b9225..dae5f0b 100644
--- a/dhpython/depends.py
+++ b/dhpython/depends.py
@@ -19,15 +19,10 @@
 # THE SOFTWARE.
 
 import logging
-from dhpython import PKG_PREFIX_MAP
+from dhpython import PKG_PREFIX_MAP, MINPYCDEP
 from dhpython.pydist import parse_pydep, guess_dependency
 from dhpython.version import default, supported, VersionRange
 
-# minimum version required for py3compile/py3clean:
-MINPYCDEP = {'cpython2': 'python (>= 2.6.6-3)',
-             'cpython3': 'python3 (>= 3.2.3-3~)',
-             'pypy': 'pypy'}
-
 log = logging.getLogger(__name__)
 
 
diff --git a/dhpython/pydist.py b/dhpython/pydist.py
index 7d03e02..3213029 100644
--- a/dhpython/pydist.py
+++ b/dhpython/pydist.py
@@ -24,7 +24,8 @@ import os
 import re
 from os.path import exists, isdir, join
 from subprocess import PIPE, Popen
-from dhpython import PKG_PREFIX_MAP
+from dhpython import PKG_PREFIX_MAP, PYDIST_DIRS, PYDIST_OVERRIDES_FNAMES,\
+    PYDIST_DPKG_SEARCH_TPLS
 from dhpython.version import get_requested_versions, Version
 from dhpython.tools import memoize
 
@@ -55,21 +56,6 @@ REQUIRES_RE = re.compile(r'''
         (?P<version>(\w|[-.])+)
     )?
     ''', re.VERBOSE)
-PYDIST_DIRS = {
-    'cpython2': '/usr/share/python/dist/',
-    'cpython3': '/usr/share/python3/dist/',
-    'pypy': '/usr/share/pypy/dist/',
-}
-OVERRIDES_FILE_NAMES = {
-    'cpython2': 'debian/pydist-overrides',
-    'cpython3': 'debian/py3dist-overrides',
-    'pypy': 'debian/pypydist-overrides',
-}
-DPKG_SEARCH_TPLS = {
-    'cpython2': "*/%s-?*\.egg-info | grep '/python2\../\|/pyshared/'",
-    'cpython3': '*python3/*/{}-?*\.egg-info',
-    'pypy': '*pypy/*/{}-?\.egg-info'
-}
 
 
 def validate(fpath):
@@ -93,7 +79,7 @@ def load(impl):
     :param impl: interpreter implementation, f.e. cpython2, cpython3, pypy
     :type impl: str
     """
-    fname = OVERRIDES_FILE_NAMES.get(impl)
+    fname = PYDIST_OVERRIDES_FNAMES.get(impl)
     if exists(fname):
         to_check = [fname]  # first one!
     else:
@@ -168,7 +154,7 @@ def guess_dependency(impl, req, version=None):
                 return item['dependency']
 
     # try dpkg -S
-    query = DPKG_SEARCH_TPLS[impl].format(ci_regexp(safe_name(name)))
+    query = PYDIST_DPKG_SEARCH_TPLS[impl].format(ci_regexp(safe_name(name)))
 
     log.debug("invoking dpkg -S %s", query)
     process = Popen("/usr/bin/dpkg -S %s" % query,
@@ -297,5 +283,5 @@ def _translate(version, rules, standard):
         else:
             log.warn('unknown rule ignored: %s', rule)
     if standard == 'PEP386':
-        version = PRE_VER_RE.sub('~\g<1>', version)
+        version = PRE_VER_RE.sub(r'~\g<1>', version)
     return version

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



More information about the Reproducible-builds mailing list