[Reproducible-builds] [dh-python] 140/183: Interpreter: add include_dir property

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Sep 19 15:30:30 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 4e66b7db82882cc719e38728e9860f5099af2e87
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Thu Oct 17 21:40:50 2013 +0200

    Interpreter: add include_dir property
---
 dhpython/interpreter.py | 41 +++++++++++++++++++++++++++++++++++++----
 pybuild.rst             |  1 +
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/dhpython/interpreter.py b/dhpython/interpreter.py
index 8d9a574..7967512 100644
--- a/dhpython/interpreter.py
+++ b/dhpython/interpreter.py
@@ -342,7 +342,7 @@ class Interpreter:
         """Return multiarch tag."""
         version = Version(version or self.version)
         try:
-            soabi, multiarch = self._get_config(version)
+            soabi, multiarch = self._get_config(version)[:2]
         except Exception:
             log.debug('cannot get multiarch', exc_info=True)
             # interpreter without multiarch support
@@ -360,13 +360,45 @@ class Interpreter:
         version = Version(version or self.version)
         # NOTE: it's not the same as magic_tag
         try:
-            soabi, multiarch = self._get_config(version)
+            soabi, multiarch = self._get_config(version)[:2]
         except Exception:
             log.debug('cannot get soabi', exc_info=True)
             # interpreter without soabi support
             return ''
         return soabi
 
+    @property
+    def include_dir(self):
+        """Return INCLUDE_DIR path.
+
+        >>> Interpreter('python2.7').include_dir
+        '/usr/include/python2.7'
+        >>> Interpreter('python3.3-dbg').include_dir
+        '/usr/include/python3.3dm'
+        """
+        if self.impl == 'pypy':
+            return '/usr/lib/pypy/include'
+        try:
+            result = self._get_config()[2]
+            if result:
+                return result
+        except Exception:
+            result = ''
+            log.debug('cannot get include path', exc_info=True)
+        result = '/usr/include/{}'.format(self.name)
+        version = self.version
+        if self.debug:
+            if version << '3.3':
+                result += '_d'
+            else:
+                result += 'dm'
+        else:
+            if version >> '3.2':
+                result += 'm'
+            elif version == '3.2':
+                result += 'mu'
+        return result
+
     def check_extname(self, fname, version=None):
         """Return extension file name if file can be renamed."""
 
@@ -394,7 +426,7 @@ class Interpreter:
             return
 
         try:
-            soabi, multiarch = self._get_config(version)
+            soabi, multiarch = self._get_config(version)[:2]
         except Exception:
             log.debug('cannot get soabi/multiarch', exc_info=True)
             return
@@ -452,7 +484,8 @@ class Interpreter:
         else:
             cmd = 'from distutils import sysconfig as s;'
         cmd += 'print("__SEP__".join(i or "" ' \
-               'for i in s.get_config_vars("SOABI", "MULTIARCH")))'
+               'for i in s.get_config_vars('\
+               '"SOABI", "MULTIARCH", "INCLUDEPY")))'
         conf_vars = self._execute(cmd, version).split('__SEP__')
         try:
             conf_vars[1] = os.environ['DEB_HOST_MULTIARCH']
diff --git a/pybuild.rst b/pybuild.rst
index 59b3c40..4050d2d 100644
--- a/pybuild.rst
+++ b/pybuild.rst
@@ -108,6 +108,7 @@ variables that can be used in `ARGUMENTS` and `COMMAND`
 * `{version}` will be replaced with current Python version,
   you can also use `{version.major}`, `{version.minor}`, etc.
 * `{interpreter}` will be replaced with current interpreter,
+  you can also use `{interpreter.include_dir}`
 * `{dir}` will be replaced with sources directory,
 * `{destdir}` will be replaced with destination directory,
 * `{home_dir}` will be replaced with temporary HOME directory,

-- 
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