about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch')
-rw-r--r--nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch b/nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch
new file mode 100644
index 000000000000..d324d10b39fc
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch
@@ -0,0 +1,54 @@
+From 45dfbbb4f5b67ab83e4365564ea569334e979f8e Mon Sep 17 00:00:00 2001
+From: Ben Wolsieffer <benwolsieffer@gmail.com>
+Date: Fri, 25 Sep 2020 16:49:16 -0400
+Subject: [PATCH] Fix finding headers when cross compiling
+
+When cross-compiling third-party extensions, get_python_inc() may be called to
+return the path to Python's headers. However, it uses the sys.prefix or
+sys.exec_prefix of the build Python, which returns incorrect paths when
+cross-compiling (paths pointing to build system headers).
+
+To fix this, we use the INCLUDEPY and CONFINCLUDEPY conf variables, which can
+be configured to point at host Python by setting _PYTHON_SYSCONFIGDATA_NAME.
+The existing behavior is maintained on non-POSIX platforms or if a prefix is
+manually specified.
+---
+ Lib/distutils/sysconfig.py | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
+index 2bcd1dd288..567375e488 100644
+--- a/Lib/distutils/sysconfig.py
++++ b/Lib/distutils/sysconfig.py
+@@ -84,8 +84,6 @@ def get_python_inc(plat_specific=0, prefix=None):
+     If 'prefix' is supplied, use it instead of sys.base_prefix or
+     sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
+     """
+-    if prefix is None:
+-        prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
+     if os.name == "posix":
+         if python_build:
+             # Assume the executable is in the build directory.  The
+@@ -98,9 +96,17 @@ def get_python_inc(plat_specific=0, prefix=None):
+             else:
+                 incdir = os.path.join(get_config_var('srcdir'), 'Include')
+                 return os.path.normpath(incdir)
+-        python_dir = 'python' + get_python_version() + build_flags
+-        return os.path.join(prefix, "include", python_dir)
++        if prefix is None:
++          if plat_specific:
++            return get_config_var('CONFINCLUDEPY')
++          else:
++            return get_config_var('INCLUDEPY')
++        else:
++          python_dir = 'python' + get_python_version() + build_flags
++          return os.path.join(prefix, "include", python_dir)
+     elif os.name == "nt":
++        if prefix is None:
++          prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
+         return os.path.join(prefix, "include")
+     else:
+         raise DistutilsPlatformError(
+-- 
+2.28.0
+