git.iko.soy/typeable/nixpkgs
on master help sign in
Enable cross compilation for cpython 2.7 (#50245)
commitd0eb502327870ebef51db7b31cbf5965cee1affe authorTravis Athougies <iammisc@gmail.com> dateThu 15 Nov 2018, 10:36 (8 years ago) parentb633e1b
2 files changed+40−2
pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch+32 pkgs/development/interpreters/python/cpython/2.7/default.nix+8−2
pkgs/development/interpreters/python/cpython/2.7/cross-compile.patchnew file+32
@@ -0,0 +1,32 @@
1+--- ./setup.py.orig 2018-04-29 15:47:33.000000000 -0700
2++++ ./setup.py 2018-11-11 09:41:58.097682221 -0800
3+@@ -458,8 +458,6 @@
4+ if not cross_compiling:
5+ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
6+ add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
7+- if cross_compiling:
8+- self.add_gcc_paths()
9+ self.add_multiarch_paths()
10+
11+ # Add paths specified in the environment variables LDFLAGS and
12+@@ -517,7 +515,10 @@
13+ # be assumed that no additional -I,-L directives are needed.
14+ inc_dirs = self.compiler.include_dirs[:]
15+ lib_dirs = self.compiler.library_dirs[:]
16+- if not cross_compiling:
17++ if cross_compiling:
18++ inc_dirs = []
19++ lib_dirs = []
20++ else:
21+ for d in (
22+ '/usr/include',
23+ ):
24+@@ -582,6 +584,8 @@ class PyBuildExt(build_ext):
25+ # Some modules that are normally always on:
26+ #exts.append( Extension('_weakref', ['_weakref.c']) )
27+
28++ self.compiler.library_dirs = lib_dirs + [ '.' ]
29++
30+ # array objects
31+ exts.append( Extension('array', ['arraymodule.c']) )
32+
pkgs/development/interpreters/python/cpython/2.7/default.nix+8−2
@@ -104,6 +104,8 @@ let
104104 # only works for GCC and Apple Clang. This makes distutils to call C++
105105 # compiler when needed.
106106 ./python-2.7-distutils-C++.patch
107+ ] ++ optional (stdenv.hostPlatform != stdenv.buildPlatform) [
108+ ./cross-compile.patch
107109 ];
108110
109111 preConfigure = ''
@@ -176,10 +178,14 @@ let
176178 LIBRARY_PATH = makeLibraryPath paths;
177179 };
178180
181+ # Python 2.7 needs this
182+ crossCompileEnv = stdenv.lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform)
183+ { _PYTHON_HOST_PLATFORM = stdenv.hostPlatform.config; };
184+
179185 # Build the basic Python interpreter without modules that have
180186 # external dependencies.
181187
182−in stdenv.mkDerivation {
188+in stdenv.mkDerivation ({
183189 name = "python-${version}";
184190 pythonVersion = majorVersion;
185191
@@ -278,4 +284,4 @@ in stdenv.mkDerivation {
278284 # in case both 2 and 3 are installed.
279285 priority = -100;
280286 };
281− }
287+ } // crossCompileEnv)