Merge pull request #66762 from adisbladis/python-minimal
python3Minimal: Add top-level for a minimal Python 3 build
This commit is contained in:
commit
65b1948be2
@ -21,6 +21,12 @@
|
|||||||
, sha256
|
, sha256
|
||||||
, passthruFun
|
, passthruFun
|
||||||
, bash
|
, bash
|
||||||
|
, stripConfig ? false
|
||||||
|
, stripIdlelib ? false
|
||||||
|
, stripTests ? false
|
||||||
|
, stripTkinter ? false
|
||||||
|
, rebuildBytecode ? true
|
||||||
|
, stripBytecode ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert x11Support -> tcl != null
|
assert x11Support -> tcl != null
|
||||||
@ -134,6 +140,7 @@ in with passthru; stdenv.mkDerivation {
|
|||||||
"--without-ensurepip"
|
"--without-ensurepip"
|
||||||
"--with-system-expat"
|
"--with-system-expat"
|
||||||
"--with-system-ffi"
|
"--with-system-ffi"
|
||||||
|
] ++ optionals (openssl != null) [
|
||||||
"--with-openssl=${openssl.dev}"
|
"--with-openssl=${openssl.dev}"
|
||||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
"ac_cv_buggy_getaddrinfo=no"
|
"ac_cv_buggy_getaddrinfo=no"
|
||||||
@ -221,8 +228,20 @@ in with passthru; stdenv.mkDerivation {
|
|||||||
find $out/lib/python*/config-* -type f -print -exec nuke-refs -e $out '{}' +
|
find $out/lib/python*/config-* -type f -print -exec nuke-refs -e $out '{}' +
|
||||||
find $out/lib -name '_sysconfigdata*.py*' -print -exec nuke-refs -e $out '{}' +
|
find $out/lib -name '_sysconfigdata*.py*' -print -exec nuke-refs -e $out '{}' +
|
||||||
|
|
||||||
|
'' + optionalString stripConfig ''
|
||||||
|
rm -R $out/bin/python*-config $out/lib/python*/config-*
|
||||||
|
'' + optionalString stripIdlelib ''
|
||||||
|
# Strip IDLE (and turtledemo, which uses it)
|
||||||
|
rm -R $out/bin/idle* $out/lib/python*/{idlelib,turtledemo}
|
||||||
|
'' + optionalString stripTkinter ''
|
||||||
|
rm -R $out/lib/python*/tkinter
|
||||||
|
'' + optionalString stripTests ''
|
||||||
|
# Strip tests
|
||||||
|
rm -R $out/lib/python*/test $out/lib/python*/**/test{,s}
|
||||||
|
'' + ''
|
||||||
# Include a sitecustomize.py file
|
# Include a sitecustomize.py file
|
||||||
cp ${../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
|
cp ${../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
|
||||||
|
'' + optionalString rebuildBytecode ''
|
||||||
|
|
||||||
# Determinism: rebuild all bytecode
|
# Determinism: rebuild all bytecode
|
||||||
# We exclude lib2to3 because that's Python 2 code which fails
|
# We exclude lib2to3 because that's Python 2 code which fails
|
||||||
@ -232,6 +251,8 @@ in with passthru; stdenv.mkDerivation {
|
|||||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
|
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
|
||||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
|
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
|
||||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
|
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 "{}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
preFixup = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||||
@ -241,9 +262,9 @@ in with passthru; stdenv.mkDerivation {
|
|||||||
|
|
||||||
# Enforce that we don't have references to the OpenSSL -dev package, which we
|
# Enforce that we don't have references to the OpenSSL -dev package, which we
|
||||||
# explicitly specify in our configure flags above.
|
# explicitly specify in our configure flags above.
|
||||||
disallowedReferences = [
|
disallowedReferences =
|
||||||
openssl.dev
|
stdenv.lib.optionals (openssl != null) [ openssl.dev ]
|
||||||
] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
# Ensure we don't have references to build-time packages.
|
# Ensure we don't have references to build-time packages.
|
||||||
# These typically end up in shebangs.
|
# These typically end up in shebangs.
|
||||||
pythonForBuild buildPackages.bash
|
pythonForBuild buildPackages.bash
|
||||||
|
@ -111,6 +111,38 @@ in {
|
|||||||
inherit passthruFun;
|
inherit passthruFun;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Minimal versions of Python (built without optional dependencies)
|
||||||
|
python3Minimal = (callPackage ./cpython {
|
||||||
|
self = python3Minimal;
|
||||||
|
sourceVersion = {
|
||||||
|
major = "3";
|
||||||
|
minor = "7";
|
||||||
|
patch = "4";
|
||||||
|
suffix = "";
|
||||||
|
};
|
||||||
|
sha256 = "0gxiv5617zd7dnqm5k9r4q2188lk327nf9jznwq9j6b8p0s92ygv";
|
||||||
|
inherit (darwin) CF configd;
|
||||||
|
inherit passthruFun;
|
||||||
|
|
||||||
|
# strip down that python version as much as possible
|
||||||
|
openssl = null;
|
||||||
|
readline = null;
|
||||||
|
ncurses = null;
|
||||||
|
gdbm = null;
|
||||||
|
sqlite = null;
|
||||||
|
stripConfig = true;
|
||||||
|
stripIdlelib = true;
|
||||||
|
stripTests = true;
|
||||||
|
stripTkinter = true;
|
||||||
|
rebuildBytecode = false;
|
||||||
|
stripBytecode = true;
|
||||||
|
}).overrideAttrs(old: {
|
||||||
|
pname = "python3-minimal";
|
||||||
|
meta = old.meta // {
|
||||||
|
maintainers = [];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
pypy27 = callPackage ./pypy {
|
pypy27 = callPackage ./pypy {
|
||||||
self = pypy27;
|
self = pypy27;
|
||||||
sourceVersion = {
|
sourceVersion = {
|
||||||
|
@ -8766,7 +8766,7 @@ in
|
|||||||
python3Packages = python3.pkgs;
|
python3Packages = python3.pkgs;
|
||||||
|
|
||||||
pythonInterpreters = callPackage ./../development/interpreters/python {};
|
pythonInterpreters = callPackage ./../development/interpreters/python {};
|
||||||
inherit (pythonInterpreters) python27 python35 python36 python37 python38 pypy27 pypy36;
|
inherit (pythonInterpreters) python27 python35 python36 python37 python38 python3Minimal pypy27 pypy36;
|
||||||
|
|
||||||
# Python package sets.
|
# Python package sets.
|
||||||
python27Packages = lib.hiPrioSet (recurseIntoAttrs python27.pkgs);
|
python27Packages = lib.hiPrioSet (recurseIntoAttrs python27.pkgs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user