From 62feba089ecd368b821d92992bd493935e7d789d Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Tue, 25 Oct 2016 22:35:20 +0200 Subject: [PATCH 1/3] pythonPackages.matplotlib: put tests in separate output since that saves 50 MB (see #12218). --- .../python-modules/matplotlib/default.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/matplotlib/default.nix b/pkgs/development/python-modules/matplotlib/default.nix index 5ba813deba604..9cf52ee3625ea 100644 --- a/pkgs/development/python-modules/matplotlib/default.nix +++ b/pkgs/development/python-modules/matplotlib/default.nix @@ -6,6 +6,7 @@ , enableGtk3 ? false, cairo , enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null , Cocoa, Foundation, CoreData, cf-private, libobjc, libcxx +, glibcLocales }: assert enableGhostscript -> ghostscript != null; @@ -28,8 +29,9 @@ buildPythonPackage rec { NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; XDG_RUNTIME_DIR = "/tmp"; + LC_ALL="en_US.UTF-8"; - buildInputs = [ python which sphinx stdenv ] + buildInputs = [ python which sphinx stdenv glibcLocales ] ++ stdenv.lib.optional enableGhostscript ghostscript ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa Foundation CoreData cf-private libobjc ]; @@ -61,12 +63,9 @@ buildPythonPackage rec { "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; checkPhase = '' - ${python.interpreter} tests.py - ''; + ${python.interpreter} tests.py --no-network - # The entry point for running tests, tests.py, is not included in the release. - # https://github.com/matplotlib/matplotlib/issues/6017 - doCheck = false; + ''; prePatch = '' # Failing test: ERROR: matplotlib.tests.test_style.test_use_url @@ -77,6 +76,13 @@ buildPythonPackage rec { sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py ''; + postFixup = '' + mkdir -p $tests/${python.sitePackages}/matplotlib/tests + mv $out/${python.sitePackages}/matplotlib/tests $tests/${python.sitePackages}/matplotlib/ + ''; + + outputs = [ "out" "tests" ]; + meta = with stdenv.lib; { description = "Python plotting library, making publication quality plots"; homepage = "http://matplotlib.sourceforge.net/"; From f4e2fd4832513e63845d47c0ea9f5eea36210d0f Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Tue, 25 Oct 2016 23:39:40 +0200 Subject: [PATCH 2/3] mpl fixup --- pkgs/development/python-modules/matplotlib/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/matplotlib/default.nix b/pkgs/development/python-modules/matplotlib/default.nix index 9cf52ee3625ea..aa83d8a8300f3 100644 --- a/pkgs/development/python-modules/matplotlib/default.nix +++ b/pkgs/development/python-modules/matplotlib/default.nix @@ -76,9 +76,12 @@ buildPythonPackage rec { sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py ''; + # Move tests in separate output postFixup = '' mkdir -p $tests/${python.sitePackages}/matplotlib/tests mv $out/${python.sitePackages}/matplotlib/tests $tests/${python.sitePackages}/matplotlib/ + mkdir -p $tests/nix-support + echo $out > $tests/nix-support/propagated-native-build-inputs ''; outputs = [ "out" "tests" ]; From 7ea92fc664df5bb14b5811be8a1839b9c81d854e Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Tue, 25 Oct 2016 23:41:11 +0200 Subject: [PATCH 3/3] works with buildEnv but order matters for PYTHONPATH --- pkgs/development/python-modules/matplotlib/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/matplotlib/default.nix b/pkgs/development/python-modules/matplotlib/default.nix index aa83d8a8300f3..6138fb2418c71 100644 --- a/pkgs/development/python-modules/matplotlib/default.nix +++ b/pkgs/development/python-modules/matplotlib/default.nix @@ -80,8 +80,11 @@ buildPythonPackage rec { postFixup = '' mkdir -p $tests/${python.sitePackages}/matplotlib/tests mv $out/${python.sitePackages}/matplotlib/tests $tests/${python.sitePackages}/matplotlib/ + echo "from pkgutil import extend_path; __path__ = extend_path(__path__, __name__)" >> "$out/${python.sitePackages}/matplotlib/__init__.py" + echo "from pkgutil import extend_path; __path__ = extend_path(__path__, __name__)" > "$tests/${python.sitePackages}/matplotlib/__init__.py" mkdir -p $tests/nix-support echo $out > $tests/nix-support/propagated-native-build-inputs + export PYTHONPATH="$tests/${python.sitePackages}:$PYTHONPATH" ''; outputs = [ "out" "tests" ];