diff options
Diffstat (limited to 'pkgs/development/interpreters/python/cpython/3.7/default.nix')
-rw-r--r-- | pkgs/development/interpreters/python/cpython/3.7/default.nix | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/pkgs/development/interpreters/python/cpython/3.7/default.nix b/pkgs/development/interpreters/python/cpython/3.7/default.nix index a008be707c2c..1d8b1c0eadf3 100644 --- a/pkgs/development/interpreters/python/cpython/3.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.7/default.nix @@ -14,8 +14,10 @@ , self , CF, configd , python-setup-hook +, nukeReferences # For the Python package set , packageOverrides ? (self: super: {}) +, buildPackages }: assert x11Support -> tcl != null @@ -33,12 +35,15 @@ let sitePackages = "lib/${libPrefix}/site-packages"; buildInputs = filter (p: p != null) [ - zlib bzip2 expat lzma libffi gdbm sqlite readline ncurses openssl ] + zlib bzip2 expat lzma libffi gdbm sqlite readline ncurses openssl nukeReferences ] ++ optionals x11Support [ tcl tk libX11 xproto ] ++ 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 +51,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 = "1fzi9d2gibh0wzwidyckzbywsxcsbckgsl05ryxlifxia77fhgyq"; @@ -95,6 +104,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 = '' @@ -125,7 +155,6 @@ in stdenv.mkDerivation { touch $out/lib/python${majorVersion}/test/__init__.py ln -s "$out/include/python${majorVersion}m" "$out/include/python${majorVersion}" - paxmark E $out/bin/python${majorVersion} # Python on Nix is not manylinux1 compatible. https://github.com/NixOS/nixpkgs/issues/18484 echo "manylinux1_compatible=False" >> $out/lib/${libPrefix}/_manylinux.py @@ -145,19 +174,28 @@ in stdenv.mkDerivation { # some $TMPDIR references to improve binary reproducibility. # Note that the .pyc file of _sysconfigdata.py should be regenerated! for i in $out/lib/python${majorVersion}/_sysconfigdata*.py $out/lib/python${majorVersion}/config-${majorVersion}m*/Makefile; do - sed -i $i -e "s|-I/nix/store/[^ ']*||g" -e "s|-L/nix/store/[^ ']*||g" -e "s|$TMPDIR|/no-such-path|g" + sed -i $i -e "s|$TMPDIR|/no-such-path|g" + nuke-refs $i done + # Further get rid of references. https://github.com/NixOS/nixpkgs/issues/51668 + find $out/lib/python*/config-*-* -type f -print -exec nuke-refs '{}' + + find $out/lib -name '_sysconfigdata_m*.py*' -print -exec nuke-refs '{}' + + # Determinism: rebuild all bytecode # We exclude lib2to3 because that's Python 2 code which fails # 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 - ''; + # Enforce that we don't have references to the OpenSSL -dev package, which we + # explicitly specify in our configure flags above. + disallowedReferences = [ openssl.dev ]; + passthru = let pythonPackages = callPackage ../../../../../top-level/python-packages.nix { python = self; |