[Reproducible-builds] [dh-python] 16/183: add Interpreter.parse_public_version method
Jérémy Bobbio
lunar at moszumanska.debian.org
Fri Sep 19 15:30:14 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 e9c0d487df28b2af542490ebe45d75bed155f679
Author: Piotr Ożarowski <piotr at debian.org>
Date: Sat Jun 29 22:59:24 2013 +0200
add Interpreter.parse_public_version method
---
dh_python2 | 11 +++++++----
dh_python3 | 22 +++++++++-------------
dhpython/__init__.py | 7 +++++++
dhpython/interpreter.py | 7 ++++++-
dhpython/pydist.py | 7 +++----
5 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/dh_python2 b/dh_python2
index 6516d4b..0b43c80 100755
--- a/dh_python2
+++ b/dh_python2
@@ -37,8 +37,7 @@ from dhpython.depends import Dependencies
from dhpython.interpreter import Interpreter
from dhpython.version import supported, default, Version, VersionRange, \
get_requested_versions
-from dhpython.pydist import validate as validate_pydist,\
- PUBLIC_DIR_RE
+from dhpython.pydist import validate as validate_pydist
from dhpython.tools import relative_symlink,\
fix_shebang,\
so2pyver, clean_egg_name,\
@@ -302,6 +301,7 @@ def scan(package, dname=None, options=None):
'ext': set()}
dbg_package = package.endswith('-dbg')
+ interpreter = Interpreter('python', debug=dbg_package)
if not dname:
proot = "debian/%s" % package
@@ -328,9 +328,9 @@ def scan(package, dname=None, options=None):
continue
bin_dir = private_dir = None
- public_dir = PUBLIC_DIR_RE.match(root)
+ version = interpreter.parse_public_version(root)
+ public_dir = bool(version)
if public_dir:
- version = Version(public_dir.group(1))
if root.endswith('-packages'):
r['public_vers'].add(version)
else:
@@ -625,6 +625,9 @@ def main():
options.arch is True and pdetails['arch'] == 'all':
continue
log.debug('processing package %s...', package)
+ if package.endswith('-dbg'):
+ interpreter.debug = True
+
if not private_dir:
try:
pyinstall(interpreter, package, options.vrange)
diff --git a/dh_python3 b/dh_python3
index 6298695..2572ad3 100755
--- a/dh_python3
+++ b/dh_python3
@@ -35,7 +35,7 @@ from dhpython.debhelper import DebHelper
from dhpython.depends import Dependencies
from dhpython.interpreter import Interpreter, EXTFILE_RE
from dhpython.version import supported, default, Version, VersionRange
-from dhpython.pydist import validate as validate_pydist, PUBLIC_DIR_RE
+from dhpython.pydist import validate as validate_pydist
from dhpython.tools import fix_shebang, clean_egg_name
from dhpython.option import Option
@@ -124,6 +124,7 @@ def scan(package, dname=None, options=None):
'ext': set()}
dbg_package = package.endswith('-dbg')
+ interpreter = Interpreter('python', impl='cpython3', debug=dbg_package)
if not dname:
proot = "debian/%s" % package
@@ -153,7 +154,8 @@ def scan(package, dname=None, options=None):
continue
bin_dir = private_dir = None
- public_dir = PUBLIC_DIR_RE.match(root)
+ version = interpreter.parse_public_version(root)
+ public_dir = bool(version)
if not public_dir:
for i in private_to_check:
if root.startswith(join('debian', package, i)):
@@ -230,17 +232,7 @@ def scan(package, dname=None, options=None):
continue
# assume all extensions were build for cPython
if fext == 'so':
- ver = public_dir.groups()[0]
- if not ver or len(ver) == 1:
- tagver = EXTFILE_RE.search(fn)
- if tagver is not None:
- tagver = tagver.groupdict()['ver']
- if tagver is not None:
- ver = "%s.%s" % (tagver[0], tagver[1])
- # note that if groups()[0] is empty, default Python version will be used
- tmp = "python%s-dbg" if dbg_package else "python%s"
- interpreter = Interpreter(tmp % ver)
- new_fn = interpreter.check_extname(fn)
+ new_fn = interpreter.check_extname(fn, version)
if new_fn:
new_fpath = join(root, new_fn)
if exists(new_fpath):
@@ -420,11 +412,15 @@ def main():
if not options.vrange and dh.python_version:
options.vrange = VersionRange(dh.python_version)
+ interpreter = Interpreter('python')
for package, pdetails in dh.packages.items():
if options.arch is False and pdetails['arch'] != 'all' or \
options.arch is True and pdetails['arch'] == 'all':
continue
log.debug('processing package %s...', package)
+ if package.endswith('-dbg'):
+ interpreter.debug = True
+
if not private_dir:
fix_locations(package)
stats = scan(package, private_dir, options)
diff --git a/dhpython/__init__.py b/dhpython/__init__.py
index b213956..a4bce83 100644
--- a/dhpython/__init__.py
+++ b/dhpython/__init__.py
@@ -18,6 +18,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+import re
+
PKG_PREFIX_MAP = {'cpython2': 'python',
'cpython3': 'python3',
'pypy': 'pypy'}
@@ -27,6 +29,11 @@ MINPYCDEP = {'cpython2': 'python (>= 2.6.6-3)',
'cpython3': 'python3 (>= 3.2.3-3~)',
'pypy': 'pypy'}
+PUBLIC_DIR_RE = {
+ 'cpython2': re.compile(r'.*?/usr/lib/python(2\.\d)/(site|dist)-packages'),
+ 'cpython3': re.compile(r'.*?/usr/lib/python(3(?:\.\d+)?)/dist-packages'),
+ 'pypy': re.compile(r'.*?/usr/lib/pypy/dist-packages')}
+
# Interpreter site-directories
OLD_SITE_DIRS = {
'cpython2': [
diff --git a/dhpython/interpreter.py b/dhpython/interpreter.py
index 5b5785a..7d39d27 100644
--- a/dhpython/interpreter.py
+++ b/dhpython/interpreter.py
@@ -22,7 +22,7 @@ import logging
import os
import re
from os.path import join, split
-from dhpython import OLD_SITE_DIRS
+from dhpython import OLD_SITE_DIRS, PUBLIC_DIR_RE
SHEBANG_RE = re.compile(r'''
(?:\#!\s*){0,1} # shebang prefix
@@ -257,6 +257,11 @@ class Interpreter:
return result
+ def parse_public_version(self, path):
+ """Return version assigned to site-packages path."""
+ match = PUBLIC_DIR_RE[self.impl].match(path)
+ if match:
+ return Version(match.groups(0))
def cache_file(self, fpath, version=None):
"""Given path to a .py file, return path to its .pyc/.pyo file.
diff --git a/dhpython/pydist.py b/dhpython/pydist.py
index 3213029..b7b291a 100644
--- a/dhpython/pydist.py
+++ b/dhpython/pydist.py
@@ -24,14 +24,13 @@ import os
import re
from os.path import exists, isdir, join
from subprocess import PIPE, Popen
-from dhpython import PKG_PREFIX_MAP, PYDIST_DIRS, PYDIST_OVERRIDES_FNAMES,\
- PYDIST_DPKG_SEARCH_TPLS
+from dhpython import PKG_PREFIX_MAP, PUBLIC_DIR_RE,\
+ PYDIST_DIRS, PYDIST_OVERRIDES_FNAMES, PYDIST_DPKG_SEARCH_TPLS
from dhpython.version import get_requested_versions, Version
from dhpython.tools import memoize
log = logging.getLogger(__name__)
-PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d(?:.\d+)?)/(site|dist)-packages')
PYDIST_RE = re.compile(r"""
(?P<name>[A-Za-z][A-Za-z0-9_.\-]*) # Python distribution name
\s*
@@ -184,7 +183,7 @@ def guess_dependency(impl, req, version=None):
def parse_pydep(impl, fname):
- public_dir = PUBLIC_DIR_RE.match(fname)
+ public_dir = PUBLIC_DIR_RE[impl].match(fname)
if public_dir and len(public_dir.group(1)) != 1:
ver = public_dir.group(1)
else:
--
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