From 224251d104723871fe6cc07149b57b0ac97c3ee4 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Fri, 23 Nov 2012 17:27:12 +0100 Subject: [PATCH 1/2] python-offline-distutils --- .../offline-distutils/default.nix | 21 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 pkgs/development/python-modules/offline-distutils/default.nix diff --git a/pkgs/development/python-modules/offline-distutils/default.nix b/pkgs/development/python-modules/offline-distutils/default.nix new file mode 100644 index 000000000000..2ed41b08bb71 --- /dev/null +++ b/pkgs/development/python-modules/offline-distutils/default.nix @@ -0,0 +1,21 @@ +# Used during module installation to prevent easy_install and python +# setup.py install/test from downloading + +{ stdenv, python }: + +stdenv.mkDerivation { + name = "python-offline-distutils-${python.version}"; + + buildInputs = [ python ]; + + unpackPhase = "true"; + installPhase = '' + dst="$out/lib/${python.libPrefix}" + ensureDir $dst/distutils + ln -s ${python}/lib/${python.libPrefix}/distutils/* $dst/distutils/ + cat < $dst/distutils/distutils.cfg +[easy_install] +allow-hosts = None +EOF + ''; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 761f63d4be6d..318ce39022e2 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -18,6 +18,10 @@ let pythonPackages = python.modules // rec { inherit python wrapPython; }; + offlineDistutils = import ../development/python-modules/offline-distutils { + inherit (pkgs) stdenv; + inherit python; + }; ipython = import ../shells/ipython { inherit (pkgs) stdenv fetchurl; From ad8a4c73fa487deb2a1f2d4814f50acb8a647f5e Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Fri, 23 Nov 2012 17:27:55 +0100 Subject: [PATCH 2/2] use offline-disutils in buildPythonPackage --- pkgs/development/python-modules/generic/builder.sh | 10 ++++++++++ pkgs/development/python-modules/generic/default.nix | 4 +++- pkgs/top-level/python-packages.nix | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/python-modules/generic/builder.sh diff --git a/pkgs/development/python-modules/generic/builder.sh b/pkgs/development/python-modules/generic/builder.sh new file mode 100644 index 000000000000..52b66aaf6a67 --- /dev/null +++ b/pkgs/development/python-modules/generic/builder.sh @@ -0,0 +1,10 @@ +source $stdenv/setup + +# do not allow distutils to make downloads, whatever install command is used +export PYTHONPATH="${setuptools}/lib/${python.libPrefix}:$PYTHONPATH" +export PYTHONPATH="${offlineDistutils}/lib/${python.libPrefix}:$PYTHONPATH" + +# enable pth files for dependencies +export PYTHONPATH="${site}/lib/${python.libPrefix}/site-packages:$PYTHONPATH" + +genericBuild diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index 4e0b61002316..394bfcbc7cd0 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -3,7 +3,7 @@ (http://pypi.python.org/pypi/setuptools/), which represents a large number of Python packages nowadays. */ -{ python, setuptools, wrapPython, lib }: +{ python, setuptools, wrapPython, lib, offlineDistutils }: { name, namePrefix ? "python-" @@ -45,6 +45,8 @@ python.stdenv.mkDerivation (attrs // { buildInputs = [ python wrapPython setuptools ] ++ buildInputs ++ pythonPath; + builder = ./builder.sh + pythonPath = [ setuptools] ++ pythonPath; # XXX: Should we run `easy_install --always-unzip'? It doesn't seem diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 318ce39022e2..cc8aea98cf55 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9,7 +9,7 @@ let pythonPackages = python.modules // rec { buildPythonPackage = import ../development/python-modules/generic { inherit (pkgs) lib; - inherit python wrapPython setuptools; + inherit python wrapPython setuptools offlineDistutils; };