aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/python/cpython/default.nix')
-rw-r--r--nixpkgs/pkgs/development/interpreters/python/cpython/default.nix50
1 files changed, 46 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix b/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix
index 3ad4021d6df..b25d613eb7f 100644
--- a/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix
+++ b/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix
@@ -9,9 +9,11 @@
, readline
, sqlite
, tcl ? null, tk ? null, tix ? null, libX11 ? null, xorgproto ? null, x11Support ? false
+, bluez ? null, bluezSupport ? false
, zlib
, self
, configd
+, autoreconfHook
, python-setup-hook
, nukeReferences
# For the Python package set
@@ -30,12 +32,23 @@
, stripBytecode ? false
, includeSiteCustomize ? true
, static ? false
+# Not using optimizations on Darwin
+# configure: error: llvm-profdata is required for a --enable-optimizations build but could not be found.
+, enableOptimizations ? (!stdenv.isDarwin)
}:
+# Note: this package is used for bootstrapping fetchurl, and thus
+# cannot use fetchpatch! All mutable patches (generated by GitHub or
+# cgit) that are needed here should be included directly in Nixpkgs as
+# files.
+
assert x11Support -> tcl != null
&& tk != null
&& xorgproto != null
&& libX11 != null;
+
+assert bluezSupport -> bluez != null;
+
with stdenv.lib;
let
@@ -52,7 +65,9 @@ let
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
- nativeBuildInputs = [
+ nativeBuildInputs = optionals (!stdenv.isDarwin) [
+ autoreconfHook
+ ] ++ [
nukeReferences
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.stdenv.cc
@@ -62,6 +77,7 @@ let
buildInputs = filter (p: p != null) ([
zlib bzip2 expat lzma libffi gdbm sqlite readline ncurses openssl ]
++ optionals x11Support [ tcl tk libX11 xorgproto ]
+ ++ optionals (bluezSupport && stdenv.isLinux) [ bluez ]
++ optionals stdenv.isDarwin [ configd ]);
hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
@@ -107,9 +123,17 @@ in with passthru; stdenv.mkDerivation {
# Backport a fix for discovering `rpmbuild` command when doing `python setup.py bdist_rpm` to 3.5, 3.6, 3.7.
# See: https://bugs.python.org/issue11122
./3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
- ] ++ optionals (isPy37 || isPy38) [
+ ] ++ optionals (isPy37 || isPy38 || isPy39) [
# Fix darwin build https://bugs.python.org/issue34027
./3.7/darwin-libutil.patch
+ ] ++ optionals (pythonOlder "3.8") [
+ # Backport from CPython 3.8 of a good list of tests to run for PGO.
+ (
+ if isPy36 || isPy37 then
+ ./3.6/profile-task.patch
+ else
+ ./3.5/profile-task.patch
+ )
] ++ optionals (isPy3k && hasDistutilsCxxPatch) [
# Fix for http://bugs.python.org/issue1222585
# Upstream distutils is calling C compiler to compile C++ code, which
@@ -118,7 +142,7 @@ in with passthru; stdenv.mkDerivation {
(
if isPy35 then
./3.5/python-3.x-distutils-C++.patch
- else if isPy37 || isPy38 then
+ else if isPy37 || isPy38 || isPy39 then
./3.7/python-3.x-distutils-C++.patch
else
fetchpatch {
@@ -126,9 +150,14 @@ in with passthru; stdenv.mkDerivation {
sha256 = "1h18lnpx539h5lfxyk379dxwr8m2raigcjixkf133l4xy3f4bzi2";
}
)
+ ] ++ [
+ # LDSHARED now uses $CC instead of gcc. Fixes cross-compilation of extension modules.
+ ./3.8/0001-On-all-posix-systems-not-just-Darwin-set-LDSHARED-if.patch
];
postPatch = ''
+ substituteInPlace Lib/subprocess.py \
+ --replace "'/bin/sh'" "'${bash}/bin/sh'"
'' + optionalString (x11Support && (tix != null)) ''
substituteInPlace "Lib/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
'';
@@ -142,10 +171,14 @@ in with passthru; stdenv.mkDerivation {
configureFlags = [
"--enable-shared"
- "--with-threads"
"--without-ensurepip"
"--with-system-expat"
"--with-system-ffi"
+ ] ++ optionals enableOptimizations [
+ "--enable-optimizations"
+ ] ++ optionals (pythonOlder "3.7") [
+ # This is unconditionally true starting in CPython 3.7.
+ "--with-threads"
] ++ optionals (sqlite != null && isPy3k) [
"--enable-loadable-sqlite-extensions"
] ++ optionals (openssl != null) [
@@ -258,6 +291,13 @@ in with passthru; stdenv.mkDerivation {
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
'' + optionalString stripBytecode ''
find $out -type d -name __pycache__ -print0 | xargs -0 -I {} rm -rf "{}"
+ '' + ''
+ # *strip* shebang from libpython gdb script - it should be dual-syntax and
+ # interpretable by whatever python the gdb in question is using, which may
+ # not even match the major version of this python. doing this after the
+ # bytecode compilations for the same reason.
+ mkdir -p $out/share/gdb
+ sed '/^#!/d' Tools/gdb/libpython.py > $out/share/gdb/libpython.py
'';
preFixup = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
@@ -275,6 +315,8 @@ in with passthru; stdenv.mkDerivation {
pythonForBuild buildPackages.bash
];
+ separateDebugInfo = true;
+
inherit passthru;
enableParallelBuilding = true;