From 107c035bf04e1b7d133d31cf8f8d6a44ef6ae136 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 14 Oct 2016 17:49:51 +0200 Subject: [PATCH] Python: remove pythonSmall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In #19309 a separate output for tkinter was added. Several dependencies of Python depend indirectly on Python. We have the following two paths: ``` ‘python-2.7.12’ - ‘tk-8.6.6’ - ‘libXft-2.3.2’ - ‘libXrender-0.9.10’ - ‘libX11-1.6.4’ - ‘libxcb-1.12’ - ‘libxslt-1.1.29’- ‘libxml2-2.9.4’ - ‘python-2.7.12’ ‘python-2.7.12’ - ‘tk-8.6.6’ - ‘libXft-2.3.2’ - ‘fontconfig-2.12.1’ - ‘dejavu-fonts-2.37’ - ‘fontforge-20160404’ - ‘python-2.7.12’ ``` Because only `tkinter` needs this, I added ``` pythonSmall = python.override {x11Support = false;}; ``` to break the infinite recursion. We also still have the output `tkinter`. However, we might as well build without x11Support by default. Then we build with x11Support as well so we get the tkinter module and put that in a separate package. --- doc/languages-frameworks/python.md | 2 +- .../python/cpython/2.7/default.nix | 10 +--------- .../python/cpython/3.3/default.nix | 8 +------- .../python/cpython/3.4/default.nix | 8 +------- .../python/cpython/3.5/default.nix | 9 +-------- .../python/cpython/3.6/default.nix | 10 +--------- pkgs/top-level/all-packages.nix | 13 +------------ pkgs/top-level/python-packages.nix | 18 +++++++++++------- 8 files changed, 18 insertions(+), 60 deletions(-) diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index f9a8f38af3db..94f277f0c088 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -422,7 +422,7 @@ exists. #### Missing `tkinter` module standard library -To reduce closure size the `Tkinter`/`tkinter` is put in a separate output. The `tkinter` is available as `python35Packages.tkinter`. +To reduce closure size the `Tkinter`/`tkinter` is available as a separate package, `pythonPackages.tkinter`. #### Attributes on interpreters packages diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index b1c64020fe9a..aa4fca9bf356 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -6,7 +6,7 @@ , openssl , readline , sqlite -, tcl ? null, tk ? null, xlibsWrapper ? null, libX11 ? null, x11Support ? !stdenv.isCygwin +, tcl ? null, tk ? null, xlibsWrapper ? null, libX11 ? null, x11Support ? false , zlib , callPackage , self @@ -170,14 +170,6 @@ in stdenv.mkDerivation { rm "$out"/lib/python*/plat-*/regen # refers to glibc.dev ''; - postFixup = optionalString x11Support '' - # tkinter goes in a separate output - mkdir -p $tkinter/${sitePackages} - mv $out/lib/${libPrefix}/lib-dynload/_tkinter* $tkinter/${sitePackages}/ - ''; - - outputs = ["out"] ++ optional x11Support "tkinter"; - passthru = rec { inherit libPrefix sitePackages x11Support; executable = libPrefix; diff --git a/pkgs/development/interpreters/python/cpython/3.3/default.nix b/pkgs/development/interpreters/python/cpython/3.3/default.nix index 478a3c96dd9a..9ac9d81c9c99 100644 --- a/pkgs/development/interpreters/python/cpython/3.3/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.3/default.nix @@ -6,7 +6,7 @@ , openssl , readline , sqlite -, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? !stdenv.isCygwin +, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? false , zlib , callPackage , self @@ -92,14 +92,8 @@ in stdenv.mkDerivation { # FIXME: should regenerate this. rm $out/lib/python${majorVersion}/__pycache__/_sysconfigdata.cpython* - '' + optionalString x11Support '' - # tkinter goes in a separate output - mkdir -p $tkinter/${sitePackages} - mv $out/lib/${libPrefix}/lib-dynload/_tkinter* $tkinter/${sitePackages}/ ''; - outputs = ["out"] ++ optional x11Support "tkinter"; - passthru = rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; diff --git a/pkgs/development/interpreters/python/cpython/3.4/default.nix b/pkgs/development/interpreters/python/cpython/3.4/default.nix index 0e0dc4acfca6..68bee72d33d7 100644 --- a/pkgs/development/interpreters/python/cpython/3.4/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.4/default.nix @@ -6,7 +6,7 @@ , openssl , readline , sqlite -, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? !stdenv.isCygwin +, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? false , zlib , callPackage , self @@ -101,14 +101,8 @@ in stdenv.mkDerivation { # FIXME: should regenerate this. rm $out/lib/python${majorVersion}/__pycache__/_sysconfigdata.cpython* - '' + optionalString x11Support '' - # tkinter goes in a separate output - mkdir -p $tkinter/${sitePackages} - mv $out/lib/${libPrefix}/lib-dynload/_tkinter* $tkinter/${sitePackages}/ ''; - outputs = ["out"] ++ optional x11Support "tkinter"; - passthru = rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; diff --git a/pkgs/development/interpreters/python/cpython/3.5/default.nix b/pkgs/development/interpreters/python/cpython/3.5/default.nix index b7839d9f4a13..7a9a9c746228 100644 --- a/pkgs/development/interpreters/python/cpython/3.5/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.5/default.nix @@ -6,7 +6,7 @@ , openssl , readline , sqlite -, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? !stdenv.isCygwin +, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? false , zlib , callPackage , self @@ -100,15 +100,8 @@ in stdenv.mkDerivation { # FIXME: should regenerate this. rm $out/lib/python${majorVersion}/__pycache__/_sysconfigdata.cpython* - - '' + optionalString x11Support '' - # tkinter goes in a separate output - mkdir -p $tkinter/${sitePackages} - mv $out/lib/${libPrefix}/lib-dynload/_tkinter* $tkinter/${sitePackages}/ ''; - outputs = ["out"] ++ optional x11Support "tkinter"; - passthru = rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; diff --git a/pkgs/development/interpreters/python/cpython/3.6/default.nix b/pkgs/development/interpreters/python/cpython/3.6/default.nix index 4c91aaf8978d..29b139178dab 100644 --- a/pkgs/development/interpreters/python/cpython/3.6/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.6/default.nix @@ -7,7 +7,7 @@ , openssl , readline , sqlite -, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? !stdenv.isCygwin +, tcl ? null, tk ? null, libX11 ? null, xproto ? null, x11Support ? false , zlib , callPackage , self @@ -91,14 +91,6 @@ in stdenv.mkDerivation { echo "manylinux1_compatible=False" >> $out/lib/${libPrefix}/_manylinux.py ''; - postFixup = optionalString x11Support '' - # tkinter goes in a separate output - mkdir -p $tkinter/${sitePackages} - mv $out/lib/${libPrefix}/lib-dynload/_tkinter* $tkinter/${sitePackages}/ - ''; - - outputs = ["out"] ++ optional x11Support "tkinter"; - passthru = rec { inherit libPrefix sitePackages x11Support; executable = "${libPrefix}m"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bc5620e06e39..9a1163ad5da6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1663,7 +1663,6 @@ in fontforge = lowPrio (callPackage ../tools/misc/fontforge { inherit (darwin.apple_sdk.frameworks) Carbon Cocoa; - python = pythonSmall; }); fontforge-gtk = callPackage ../tools/misc/fontforge { withGTK = true; @@ -5494,11 +5493,6 @@ in python2 = python27; python3 = python35; - # Python uses multiple outputs, and by default `python` is without X11/tkinter. - # This package only exists to prevent an infinite recursion and should only be used - # for packages Python itself depends on. - pythonSmall = python.override {x11Support = false;}; - # pythonPackages further below, but assigned here because they need to be in sync pythonPackages = python2Packages; python2Packages = python27Packages; @@ -7144,7 +7138,6 @@ in gtkmathview = callPackage ../development/libraries/gtkmathview { }; glib = callPackage ../development/libraries/glib { - python = pythonSmall; }; glib-tested = glib.override { # checked version separate to break cycles doCheck = true; @@ -8269,7 +8262,6 @@ in libxmi = callPackage ../development/libraries/libxmi { }; libxml2 = callPackage ../development/libraries/libxml2 { - python = pythonSmall; }; libxml2Python = pkgs.buildEnv { # slightly hacky name = "libxml2+py-${self.libxml2.version}"; @@ -10364,7 +10356,6 @@ in inherit (darwin) apple_sdk cf-private libobjc; bootstrap_cmds = if stdenv.isDarwin then darwin.bootstrap_cmds else null; mesa = mesa_noglu; - python = pythonSmall; udev = if stdenv.isLinux then udev else null; libdrm = if stdenv.isLinux then libdrm else null; fglrxCompat = config.xorg.fglrxCompat or false; # `config` because we have no `xorg.override` @@ -11516,9 +11507,7 @@ in bgnet = callPackage ../data/documentation/bgnet { }; - cacert = callPackage ../data/misc/cacert { - python = pythonSmall; - }; + cacert = callPackage ../data/misc/cacert { }; caladea = callPackage ../data/fonts/caladea {}; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5f6c2e2ac885..b2256b6b6080 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -24675,20 +24675,24 @@ in { }; # Tkinter/tkinter is part of the Python standard library. - # To reduce closure size its put in a separate output, `python.tkinter`. - # This alias was added to make this output work like any other Python package. - tkinter = mkPythonDerivation rec { + # The Python interpreters in Nixpkgs come without tkinter by default. + # To make the module available, we make it available as any other + # Python package. + tkinter = let + py = python.override{x11Support=true;}; + in mkPythonDerivation rec { name = "tkinter-${python.version}"; - src = python.tkinter; + src = py; disabled = isPy26 || isPyPy; installPhase = '' - mkdir -p $out - cp -R ${python.tkinter}/* $out + mkdir -p $out/${py.sitePackages} + ls -Al lib/${py.libPrefix}/lib-dynload/ | grep tkinter + mv lib/${py.libPrefix}/lib-dynload/_tkinter* $out/${py.sitePackages}/ ''; - inherit (python) meta; + inherit (py) meta; }; tlslite = buildPythonPackage rec {