Description: debianization
 Meant to maintain a minimal debian/rules, to fix warnings, to address
 Debian specific stuff in general. This is a Debian centric patch.
Origin: vendor, Debian
Forwarded: not-needed
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2016-11-04

--- a/src/scripts/cysignals-CSI
+++ b/src/scripts/cysignals-CSI
@@ -97,6 +97,7 @@
     """
     # Preload the right Python library
     libpython = os.path.join(sysconfig.get_config_var('exec_prefix'), 'lib',
+                             sysconfig.get_config_var('MULTIARCH'),
                              sysconfig.get_config_var('INSTSONAME'))
     env = dict(os.environ)
     if sys.platform == 'macosx':
--- a/setup.py
+++ b/setup.py
@@ -24,6 +24,8 @@
 	ac_configure_flags = "--with-pari"
 	sys.argv.remove("--with-pari")
 
+env_PYBUILD_DESTDIR = os.environ.get("PYBUILD_DESTDIR")
+
 cythonize_dir = "build/XXXX"
 if "--without-pari" in ac_configure_flags:
 	cythonize_dir = "build/bare"
@@ -132,8 +134,12 @@
         # The variable "init_pxd" is the string which should be written to
         # __init__.pxd
         init_pxd = "# distutils: include_dirs = {0}\n".format(install_dir)
-        # Append __init__.pxd from configure
-        init_pxd += self.get_init_pxd()
+
+        if env_PYBUILD_DESTDIR is None:
+            # Append __init__.pxd from configure
+            init_pxd += self.get_init_pxd()
+        else:
+            init_pxd = init_pxd.replace(env_PYBUILD_DESTDIR,"")
 
         init_pxd_file = opj(self.build_lib, "cysignals", "__init__.pxd")
         write_if_changed(init_pxd_file, init_pxd)
