Skip to content

Commit

Permalink
Python: fixed-point combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
FRidh committed Sep 26, 2016
1 parent 9e2c489 commit 70598d3
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 139 deletions.
9 changes: 5 additions & 4 deletions pkgs/development/interpreters/python/cpython/2.6/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false
, sqlite, tcl, tk, xlibsWrapper, openssl, readline, db, ncurses, gdbm, self, callPackage
, python26Packages }:
, pkgOverrides ? (self: super: {})
, pkgs
}:

assert zlibSupport -> zlib != null;

Expand Down Expand Up @@ -97,13 +99,12 @@ let
inherit zlibSupport;
isPy2 = true;
isPy26 = true;
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python26Packages; };
libPrefix = "python${majorVersion}";
executable = libPrefix;
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});


enableParallelBuilding = true;

Expand Down
10 changes: 6 additions & 4 deletions pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, self, callPackage, python27Packages
{ stdenv, fetchurl, self, callPackage
, bzip2, openssl, gettext

, includeModules ? false
Expand All @@ -9,6 +9,10 @@
, zlib ? null, zlibSupport ? true
, expat, libffi


, pkgOverrides ? (self: super: {})
, pkgs

, CF, configd
}:

Expand Down Expand Up @@ -159,13 +163,11 @@ let
inherit zlibSupport;
isPy2 = true;
isPy27 = true;
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python27Packages; };
libPrefix = "python${majorVersion}";
executable = libPrefix;
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});

enableParallelBuilding = true;

Expand Down
8 changes: 4 additions & 4 deletions pkgs/development/interpreters/python/cpython/3.3/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
, zlib
, callPackage
, self
, python33Packages
, pkgOverrides ? (self: super: {})
, pkgs
}:

assert readline != null -> ncurses != null;
Expand Down Expand Up @@ -82,14 +83,13 @@ stdenv.mkDerivation {
tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null);
libPrefix = "python${majorVersion}";
executable = "python3.3m";
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python33Packages; };
isPy3 = true;
isPy33 = true;
is_py3k = true; # deprecated
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});


enableParallelBuilding = true;

Expand Down
10 changes: 4 additions & 6 deletions pkgs/development/interpreters/python/cpython/3.4/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
, zlib
, callPackage
, self
, python34Packages

, pkgOverrides ? (self: super: {})
, pkgs
, CF, configd
}:

Expand Down Expand Up @@ -106,14 +106,12 @@ stdenv.mkDerivation {
tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null);
libPrefix = "python${majorVersion}";
executable = "python3.4m";
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python34Packages; };
isPy3 = true;
isPy34 = true;
is_py3k = true; # deprecated
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});


enableParallelBuilding = true;

Expand Down
9 changes: 4 additions & 5 deletions pkgs/development/interpreters/python/cpython/3.5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
, zlib
, callPackage
, self
, python35Packages

, pkgOverrides ? (self: super: {})
, pkgs
, CF, configd

}:

assert readline != null -> ncurses != null;
Expand Down Expand Up @@ -114,14 +115,12 @@ stdenv.mkDerivation {
tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null);
libPrefix = "python${majorVersion}";
executable = "python${majorVersion}m";
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python35Packages; };
isPy3 = true;
isPy35 = true;
is_py3k = true; # deprecated
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});

enableParallelBuilding = true;

Expand Down
9 changes: 4 additions & 5 deletions pkgs/development/interpreters/python/cpython/3.6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
, zlib
, callPackage
, self
, python36Packages

, pkgOverrides ? (self: super: {})
, pkgs
, CF, configd
}:

Expand Down Expand Up @@ -109,14 +109,13 @@ stdenv.mkDerivation {
tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null);
libPrefix = "python${majorVersion}";
executable = "python${majorVersion}m";
buildEnv = callPackage ../../wrapper.nix { python = self; };
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python36Packages; };
isPy3 = true;
isPy35 = true;
is_py3k = true; # deprecated
sitePackages = "lib/${libPrefix}/site-packages";
interpreter = "${self}/bin/${executable}";
};
} // (import ../../interpreter.nix {inherit stdenv pkgs; overrides=pkgOverrides; python=self;});


enableParallelBuilding = true;

Expand Down
71 changes: 71 additions & 0 deletions pkgs/development/interpreters/python/interpreter.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ stdenv
, pkgs
, python
#, pythonConfig ? (self: super: {})
, overrides ? (self: super: {})
}:

let
inherit (stdenv) lib;

# Package set
packages = let

inherit (lib) fix' extends fold;

pythonPackages = self: import ./support.nix {
inherit pkgs python setuptools;
} self;

commonConfiguration = import ../../../top-level/python-packages.nix { inherit pkgs stdenv; };

#in fix' (fold extends [ overrides commonConfiguration pythonPackages ]);
in fix' (extends overrides (extends commonConfiguration pythonPackages));

# Function to build an environment
buildEnv = import ./wrapper.nix {
inherit stdenv python;
inherit (pkgs) buildEnv makeWrapper;
};

# Function to build an environment, but accepting only a list of packages
withPackages = import ./with-packages.nix {
inherit buildEnv;
pythonPackages = packages;
};

# Derivation with scripts for building wrappers
wrapPython = import ./wrap-python.nix {
inherit lib python;
inherit (pkgs) makeSetupHook makeWrapper;
};

# Setuptools derivation
setuptools = import ../../python-modules/setuptools {
inherit stdenv lib python wrapPython;
inherit (pkgs) fetchurl;
};

# Function to build a package that doesn't use setuptools
mkPythonDerivation = import ./mk-python-derivation.nix {
inherit lib python wrapPython setuptools;
inherit (pkgs) unzip ensureNewerSourcesHook;
};

# Function to build a package that uses setuptools or installs a wheel
buildPythonPackage = lib.makeOverridable ( import ./build-python-package.nix {
inherit lib python mkPythonDerivation;
bootstrapped-pip = import ../../python-modules/bootstrapped-pip {
inherit stdenv python;
inherit (pkgs) fetchurl makeWrapper unzip;
};
});

in {
# For each Python interpreter version we have this set.
pkgs = packages;
inherit withPackages;
inherit buildEnv;
inherit mkPythonDerivation;
inherit buildPythonPackage;
}
4 changes: 1 addition & 3 deletions pkgs/development/interpreters/python/pypy/2.7/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi
, sqlite, openssl, ncurses, pythonFull, expat, tcl, tk, xlibsWrapper, libX11
, makeWrapper, callPackage, self, pypyPackages, gdbm, db }:
, makeWrapper, callPackage, self, gdbm, db }:

assert zlibSupport -> zlib != null;

Expand Down Expand Up @@ -119,10 +119,8 @@ let
inherit zlibSupport libPrefix;
executable = "pypy";
isPypy = true;
buildEnv = callPackage ../../wrapper.nix { python = self; };
interpreter = "${self}/bin/${executable}";
sitePackages = "site-packages";
withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = pypyPackages; };
};

enableParallelBuilding = true; # almost no parallelization without STM
Expand Down
40 changes: 40 additions & 0 deletions pkgs/development/interpreters/python/support.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{ pkgs
, python
, setuptools }:

with pkgs.lib;

self:

let
modules = python.modules or {
readline = null;
sqlite3 = null;
curses = null;
curses_panel = null;
crypt = null;
};

in rec {

inherit python;
inherit setuptools; # Packages shouldn't depend explicitly on setuptools.
inherit (python) mkPythonDerivation buildPythonPackage wrapPython ;
inherit modules;

pythonAtLeast = versionAtLeast python.pythonVersion;
pythonOlder = versionOlder python.pythonVersion;
isPy26 = python.majorVersion == "2.6";
isPy27 = python.majorVersion == "2.7";
isPy33 = python.majorVersion == "3.3";
isPy34 = python.majorVersion == "3.4";
isPy35 = python.majorVersion == "3.5";
isPy36 = python.majorVersion == "3.6";
isPyPy = python.executable == "pypy";
isPy3k = strings.substring 0 1 python.majorVersion == "3";

callPackage = pkgs.newScope self;

buildPythonApplication = args: buildPythonPackage ({namePrefix="";} // args );

} // modules
4 changes: 2 additions & 2 deletions pkgs/os-specific/linux/dstat/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, python, pythonPackages }:
{ stdenv, fetchurl, pythonPackages }:

stdenv.mkDerivation rec {
name = "dstat-${version}";
Expand All @@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
pythonPath = with pythonPackages; [ python-wifi ];

patchPhase = ''
sed -i -e 's|/usr/bin/env python|${python}/bin/python|' \
sed -i -e 's|/usr/bin/env python|${pythonPackages.python.interpreter}|' \
-e "s|/usr/share/dstat|$out/share/dstat|" dstat
'';

Expand Down
Loading

0 comments on commit 70598d3

Please sign in to comment.