From d0eb502327870ebef51db7b31cbf5965cee1affe Mon Sep 17 00:00:00 2001 From: Travis Athougies Date: Thu, 15 Nov 2018 10:36:03 -0800 Subject: Enable cross compilation for cpython 2.7 (#50245) --- .../python/cpython/2.7/cross-compile.patch | 32 ++++++++++++++++++++++ .../interpreters/python/cpython/2.7/default.nix | 10 +++++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch (limited to 'pkgs/development/interpreters/python') diff --git a/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch b/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch new file mode 100644 index 000000000000..c83b56437a49 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch @@ -0,0 +1,32 @@ +--- ./setup.py.orig 2018-04-29 15:47:33.000000000 -0700 ++++ ./setup.py 2018-11-11 09:41:58.097682221 -0800 +@@ -458,8 +458,6 @@ + if not cross_compiling: + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') +- if cross_compiling: +- self.add_gcc_paths() + self.add_multiarch_paths() + + # Add paths specified in the environment variables LDFLAGS and +@@ -517,7 +515,10 @@ + # be assumed that no additional -I,-L directives are needed. + inc_dirs = self.compiler.include_dirs[:] + lib_dirs = self.compiler.library_dirs[:] +- if not cross_compiling: ++ if cross_compiling: ++ inc_dirs = [] ++ lib_dirs = [] ++ else: + for d in ( + '/usr/include', + ): +@@ -582,6 +584,8 @@ class PyBuildExt(build_ext): + # Some modules that are normally always on: + #exts.append( Extension('_weakref', ['_weakref.c']) ) + ++ self.compiler.library_dirs = lib_dirs + [ '.' ] ++ + # array objects + exts.append( Extension('array', ['arraymodule.c']) ) + diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index 2609c053d95b..dd4c325e4685 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -104,6 +104,8 @@ let # only works for GCC and Apple Clang. This makes distutils to call C++ # compiler when needed. ./python-2.7-distutils-C++.patch + ] ++ optional (stdenv.hostPlatform != stdenv.buildPlatform) [ + ./cross-compile.patch ]; preConfigure = '' @@ -176,10 +178,14 @@ let LIBRARY_PATH = makeLibraryPath paths; }; + # Python 2.7 needs this + crossCompileEnv = stdenv.lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) + { _PYTHON_HOST_PLATFORM = stdenv.hostPlatform.config; }; + # Build the basic Python interpreter without modules that have # external dependencies. -in stdenv.mkDerivation { +in stdenv.mkDerivation ({ name = "python-${version}"; pythonVersion = majorVersion; @@ -278,4 +284,4 @@ in stdenv.mkDerivation { # in case both 2 and 3 are installed. priority = -100; }; - } + } // crossCompileEnv) -- cgit 1.4.1