summary refs log tree commit diff
path: root/pkgs/development/interpreters/python
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2011-01-03 16:25:11 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2011-01-03 16:25:11 +0000
commitc1eb464f3c6300fcf57c06942b07cb7cb66cc408 (patch)
treefebc26625afcd576ba4f075d8af81a247edd768d /pkgs/development/interpreters/python
parente1309dee31aa5221d07997bf5ed73baa36094b15 (diff)
downloadnixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar.gz
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar.bz2
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar.lz
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar.xz
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.tar.zst
nixlib-c1eb464f3c6300fcf57c06942b07cb7cb66cc408.zip
* Build those Python modules in the Python distribution that require
  additional dependencies (e.g. SQLite, X11, or Tcl/Tk) outside the
  main Python package (i.e., pythonBase).  This makes pythonFull
  unnecessary: you can just pass the additional modules as
  buildInputs to packages that require them, e.g.

    buildInputs = [ pythonModules.sqlite3 ];

svn path=/nixpkgs/branches/modular-python/; revision=25364
Diffstat (limited to 'pkgs/development/interpreters/python')
-rw-r--r--pkgs/development/interpreters/python/2.7/modules.nix70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/2.7/modules.nix b/pkgs/development/interpreters/python/2.7/modules.nix
new file mode 100644
index 000000000000..fd4c0d9c6038
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/modules.nix
@@ -0,0 +1,70 @@
+{ stdenv, python, sqlite, tcl, tk, x11, openssl, readline }:
+
+with stdenv.lib;
+
+let 
+
+  buildInternalPythonModule =
+    { moduleName
+    , internalName ? "_" + moduleName
+    , deps
+    }:
+    stdenv.mkDerivation rec {
+      name = "python-${moduleName}-${python.version}";
+
+      src = python.src;
+
+      patches = python.patches;
+
+      buildInputs = [ python ] ++ deps;
+
+      C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
+      LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
+
+      configurePhase = "true";
+
+      buildPhase =
+        ''
+          # Fake the build environment that setup.py expects.
+          ln -s ${python}/include/python*/pyconfig.h .
+          ln -s ${python}/lib/python*/config/Setup Modules/
+          ln -s ${python}/lib/python*/config/Setup.local Modules/
+
+          substituteInPlace setup.py --replace 'self.extensions = extensions' \
+            'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]'
+
+          python ./setup.py build_ext
+        '';
+
+      installPhase =
+        ''
+          dest=$out/lib/${python.libPrefix}/site-packages
+          mkdir -p $dest
+          cp -p $(find . -name "*.so") $dest/
+        '';
+    };
+
+in {
+    
+  sqlite3 = buildInternalPythonModule {
+    moduleName = "sqlite3";
+    deps = [ sqlite ];
+  };
+    
+  tkinter = buildInternalPythonModule {
+    moduleName = "tkinter";
+    deps = [ tcl tk x11 ];
+  };
+    
+  ssl = buildInternalPythonModule {
+    moduleName = "ssl";
+    deps = [ openssl ];
+  };
+    
+  readline = buildInternalPythonModule {
+    moduleName = "readline";
+    internalName = "readline";
+    deps = [ readline ];
+  };
+    
+}