From 01cc4301f36d439b4f918dbb521937c09f097e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cillian=20de=20R=C3=B3iste?= Date: Wed, 28 Aug 2013 00:26:06 +0200 Subject: [PATCH] Add a patched version of buildout 2.2.0 for development with nix Without this patch buildout will copy eggs from the nix store into the ./eggs directory and then try to compile them. This fails because they are read only. This patch changes the behaviour to create symlinks to eggs available in the nix store instead of copying them, and not to try to compile the eggs in the store. To differentiate this from the default buildout (which may be provided otherwise e.g. as a dependency) the executable is renamed to buildout-nix. This can be used in conjuntion with myEnvFun to create development environments which make use of the python modules available in the store while downloading any additional required eggs. A pleasant side effect is that you can conveniently replace the symlink with a copy for debugging purposes. --- .../python-modules/buildout-nix/default.nix | 21 +++++++++++++++++ .../python-modules/buildout-nix/nix.patch | 23 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 3 +++ 3 files changed, 47 insertions(+) create mode 100644 pkgs/development/python-modules/buildout-nix/default.nix create mode 100644 pkgs/development/python-modules/buildout-nix/nix.patch diff --git a/pkgs/development/python-modules/buildout-nix/default.nix b/pkgs/development/python-modules/buildout-nix/default.nix new file mode 100644 index 000000000000..26b6fb0cfcda --- /dev/null +++ b/pkgs/development/python-modules/buildout-nix/default.nix @@ -0,0 +1,21 @@ +{ fetchurl, stdenv, buildPythonPackage }: + +buildPythonPackage { + name = "zc.buildout-nix-2.2.0"; + + src = fetchurl { + url = "https://pypi.python.org/packages/source/z/zc.buildout/zc.buildout-2.2.0.tar.gz"; + md5 = "771dd9807da7d5ef5bb998991c5fdae1"; + }; + + patches = [ ./nix.patch ]; + + postInstall = "mv $out/bin/buildout{,-nix}"; + + meta = { + homepage = "http://www.buildout.org"; + description = "A software build and configuration system"; + license = stdenv.lib.licenses.zpt21; + maintainers = [ stdenv.lib.maintainers.goibhniu ]; + }; +} diff --git a/pkgs/development/python-modules/buildout-nix/nix.patch b/pkgs/development/python-modules/buildout-nix/nix.patch new file mode 100644 index 000000000000..a09163518a96 --- /dev/null +++ b/pkgs/development/python-modules/buildout-nix/nix.patch @@ -0,0 +1,23 @@ +--- a/src/zc/buildout/easy_install.py 2013-08-27 22:28:40.233718116 +0200 ++++ b/src/zc/buildout/easy_install.py 2013-08-27 22:31:07.967871186 +0200 +@@ -508,16 +508,15 @@ + self._dest, os.path.basename(dist.location)) + + if os.path.isdir(dist.location): +- # we got a directory. It must have been +- # obtained locally. Just copy it. +- shutil.copytree(dist.location, newloc) ++ # Symlink to dists in /nix/store ++ if not os.path.exists(newloc): ++ os.symlink(dist.location, newloc) + else: + + + setuptools.archive_util.unpack_archive( + dist.location, newloc) +- +- redo_pyc(newloc) ++ redo_pyc(newloc) + + # Getting the dist from the environment causes the + # distribution meta data to be read. Cloning isn't diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 59707c58de89..3cd30b715f07 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -126,6 +126,9 @@ pythonPackages = modules // import ./python-packages-generated.nix { inherit python buildPythonPackage pygobject pycairo; }; + # A patched version of buildout, useful for buildout based development on Nix + zc_buildout_nix = callPackage ../development/python-modules/buildout-nix { }; + # packages defined here afew = buildPythonPackage rec {