about summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/cpython
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2018-12-18 12:06:37 +0000
committerJörg Thalheim <joerg@thalheim.io>2018-12-18 12:39:24 +0000
commit14b2dcea8f62b8992d9fc7c74f5b9b62a989affb (patch)
tree2b90ed1fd0dfc30f48d6047900bf38ba19fda620 /pkgs/development/interpreters/python/cpython
parentfcce28f1af9e89cbce9d0c32899af25240c1d751 (diff)
downloadnixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar.gz
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar.bz2
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar.lz
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar.xz
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.tar.zst
nixlib-14b2dcea8f62b8992d9fc7c74f5b9b62a989affb.zip
python37: fix cross-compilation
Diffstat (limited to 'pkgs/development/interpreters/python/cpython')
-rw-r--r--pkgs/development/interpreters/python/cpython/3.7/default.nix37
1 files changed, 33 insertions, 4 deletions
diff --git a/pkgs/development/interpreters/python/cpython/3.7/default.nix b/pkgs/development/interpreters/python/cpython/3.7/default.nix
index 093d8599690c..d1403ba95e4e 100644
--- a/pkgs/development/interpreters/python/cpython/3.7/default.nix
+++ b/pkgs/development/interpreters/python/cpython/3.7/default.nix
@@ -16,6 +16,7 @@
 , python-setup-hook
 # For the Python package set
 , packageOverrides ? (self: super: {})
+, buildPackages
 }:
 
 assert x11Support -> tcl != null
@@ -38,7 +39,10 @@ let
     ++ optionals stdenv.isDarwin [ CF configd ];
 
   hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
-
+  pythonForBuild = if stdenv.hostPlatform == stdenv.buildPlatform then
+    "$out/bin/python"
+  else
+    buildPackages.python37.interpreter;
 in stdenv.mkDerivation {
   name = "python3-${version}";
   pythonVersion = majorVersion;
@@ -46,6 +50,10 @@ in stdenv.mkDerivation {
 
   inherit buildInputs;
 
+  nativeBuildInputs =
+    optionals (stdenv.hostPlatform != stdenv.buildPlatform)
+    [ buildPackages.stdenv.cc buildPackages.python37 ];
+
   src = fetchurl {
     url = "https://www.python.org/ftp/python/${majorVersion}.${minorVersion}/Python-${version}.tar.xz";
     sha256 = "0v9x4h22rh5cwpsq1mwpdi3c9lc9820lzp2nmn9g20llij72nzps";
@@ -95,6 +103,27 @@ in stdenv.mkDerivation {
     "--with-system-expat"
     "--with-system-ffi"
     "--with-openssl=${openssl.dev}"
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "ac_cv_buggy_getaddrinfo=no"
+    # Assume little-endian IEEE 754 floating point when cross compiling
+    "ac_cv_little_endian_double=yes"
+    "ac_cv_big_endian_double=no"
+    "ac_cv_mixed_endian_double=no"
+    "ac_cv_x87_double_rounding=yes"
+    "ac_cv_tanh_preserves_zero_sign=yes"
+    # Generally assume that things are present and work
+    "ac_cv_posix_semaphores_enabled=yes"
+    "ac_cv_broken_sem_getvalue=no"
+    "ac_cv_wchar_t_signed=yes"
+    "ac_cv_rshift_extends_sign=yes"
+    "ac_cv_broken_nice=no"
+    "ac_cv_broken_poll=no"
+    "ac_cv_working_tzset=yes"
+    "ac_cv_have_long_long_format=yes"
+    "ac_cv_have_size_t_format=yes"
+    "ac_cv_computed_gotos=yes"
+    "ac_cv_file__dev_ptmx=yes"
+    "ac_cv_file__dev_ptc=yes"
   ];
 
   preConfigure = ''
@@ -153,9 +182,9 @@ in stdenv.mkDerivation {
     # We rebuild three times, once for each optimization level
     # Python 3.7 implements PEP 552, introducing support for deterministic bytecode.
     # This is automatically used when `SOURCE_DATE_EPOCH` is set.
-    find $out -name "*.py" | $out/bin/python     -m compileall -q -f -x "lib2to3" -i -
-    find $out -name "*.py" | $out/bin/python -O  -m compileall -q -f -x "lib2to3" -i -
-    find $out -name "*.py" | $out/bin/python -OO -m compileall -q -f -x "lib2to3" -i -
+    find $out -name "*.py" | ${pythonForBuild}     -m compileall -q -f -x "lib2to3" -i -
+    find $out -name "*.py" | ${pythonForBuild} -O  -m compileall -q -f -x "lib2to3" -i -
+    find $out -name "*.py" | ${pythonForBuild} -OO -m compileall -q -f -x "lib2to3" -i -
   '';
 
   passthru = let