Author: eelco
Date: Mon Jan  3 16:25:11 2011
New Revision: 25364
URL: https://svn.nixos.org/websvn/nix/?rev=25364&sc=1

Log:
* 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 ];

Added:
   
nixpkgs/branches/modular-python/pkgs/development/interpreters/python/2.7/modules.nix
Modified:
   nixpkgs/branches/modular-python/pkgs/tools/networking/offlineimap/default.nix
   nixpkgs/branches/modular-python/pkgs/top-level/all-packages.nix

Added: 
nixpkgs/branches/modular-python/pkgs/development/interpreters/python/2.7/modules.nix
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
nixpkgs/branches/modular-python/pkgs/development/interpreters/python/2.7/modules.nix
        Mon Jan  3 16:25:11 2011        (r25364)
@@ -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 ];
+  };
+    
+}

Modified: 
nixpkgs/branches/modular-python/pkgs/tools/networking/offlineimap/default.nix
==============================================================================
--- 
nixpkgs/branches/modular-python/pkgs/tools/networking/offlineimap/default.nix   
    Mon Jan  3 16:12:19 2011        (r25363)
+++ 
nixpkgs/branches/modular-python/pkgs/tools/networking/offlineimap/default.nix   
    Mon Jan  3 16:25:11 2011        (r25364)
@@ -1,4 +1,4 @@
-{fetchurl, buildPythonPackage}:
+{ fetchurl, buildPythonPackage, ssl }:
 
 buildPythonPackage {
   name = "offlineimap-6.2.0.2";
@@ -8,10 +8,9 @@
     sha256 = "1w69qv1dm37m53k8cd068lk5z3qjlscnjxr397gs8kdsfds67v7c";
   };
 
-  doCheck = false;
+  propagatedBuildInputs = [ ssl ];
 
-  preConfigure = "set -x";
-  buildInputs = [ ];
+  doCheck = false;
 
   meta = {
     description = "IMAP to local files bridge";

Modified: nixpkgs/branches/modular-python/pkgs/top-level/all-packages.nix
==============================================================================
--- nixpkgs/branches/modular-python/pkgs/top-level/all-packages.nix     Mon Jan 
 3 16:12:19 2011        (r25363)
+++ nixpkgs/branches/modular-python/pkgs/top-level/all-packages.nix     Mon Jan 
 3 16:25:11 2011        (r25364)
@@ -964,17 +964,8 @@
 
   offlineimap = import ../tools/networking/offlineimap {
     inherit fetchurl;
-    # I did not find any better way of reusing buildPythonPackage+setuptools
-    # for a python with openssl support
-    buildPythonPackage = assert pythonFull.opensslSupport;
-      import ../development/python-modules/generic {
-        inherit makeWrapper lib;
-        python = pythonFull;
-        setuptools = builderDefsPackage (import 
../development/python-modules/setuptools) {
-          inherit makeWrapper;
-          python = pythonFull;
-        };
-      };
+    buildPythonPackage = buildPython27Package;
+    ssl = pythonModules.ssl;
   };
 
   opendbx = callPackage ../development/libraries/opendbx { };
@@ -2314,6 +2305,10 @@
     inherit (pkgs.xlibs) libX11 xproto;
   });
 
+  pythonModules = callPackage 
../development/interpreters/python/2.7/modules.nix {
+    python = python27Base;
+  };
+
   python31Base = lowPrio (makeOverridable (import 
../development/interpreters/python/3.1) {
     inherit (pkgs) fetchurl stdenv zlib bzip2 gdbm;
     arch = if stdenv.isDarwin then darwinArchUtility else null;
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to