summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-04-11 13:36:04 -0400
committerShea Levy <shea@shealevy.com>2018-04-11 13:36:04 -0400
commit216b32f339eda964de086744c5e278babab2eb2c (patch)
tree7f5812525c3bcadcce8d8f1790d6a7c9a9861577 /pkgs
parent5570fc142723dee464c998d5f586cde901588f06 (diff)
parent0901b3e195834269902b0979b49b9772c447ed08 (diff)
downloadnixlib-216b32f339eda964de086744c5e278babab2eb2c.tar
nixlib-216b32f339eda964de086744c5e278babab2eb2c.tar.gz
nixlib-216b32f339eda964de086744c5e278babab2eb2c.tar.bz2
nixlib-216b32f339eda964de086744c5e278babab2eb2c.tar.lz
nixlib-216b32f339eda964de086744c5e278babab2eb2c.tar.xz
nixlib-216b32f339eda964de086744c5e278babab2eb2c.tar.zst
nixlib-216b32f339eda964de086744c5e278babab2eb2c.zip
Merge branch 'setupcfg2nix'
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/build-setupcfg/default.nix23
-rw-r--r--pkgs/development/tools/setupcfg2nix/default.nix19
-rw-r--r--pkgs/development/tools/setupcfg2nix/info.nix7
-rw-r--r--pkgs/top-level/all-packages.nix2
-rw-r--r--pkgs/top-level/python-packages.nix4
5 files changed, 55 insertions, 0 deletions
diff --git a/pkgs/build-support/build-setupcfg/default.nix b/pkgs/build-support/build-setupcfg/default.nix
new file mode 100644
index 000000000000..62dda59f1d52
--- /dev/null
+++ b/pkgs/build-support/build-setupcfg/default.nix
@@ -0,0 +1,23 @@
+# Build a python package from info made available by setupcfg2nix.
+#
+# * src: The source of the package.
+# * info: The package information generated by setupcfg2nix.
+# * meta: Standard nixpkgs metadata.
+# * application: Whether this package is a python library or an
+#   application which happens to be written in python.
+pythonPackages: { src, info, meta ? {}, application ? false }: let
+  build = if application
+    then pythonPackages.buildPythonApplication
+  else pythonPackages.buildPythonPackage;
+in build {
+  inherit (info) pname version;
+
+  inherit src meta;
+
+  nativeBuildInputs = map (p: pythonPackages.${p}) (
+    (info.setup_requires or []) ++
+    (info.tests_require or []));
+
+  propagatedBuildInputs = map (p: pythonPackages.${p})
+    (info.install_requires or []);
+}
diff --git a/pkgs/development/tools/setupcfg2nix/default.nix b/pkgs/development/tools/setupcfg2nix/default.nix
new file mode 100644
index 000000000000..5d1f015e8052
--- /dev/null
+++ b/pkgs/development/tools/setupcfg2nix/default.nix
@@ -0,0 +1,19 @@
+{ buildSetupcfg, fetchFromGitHub, lib }:
+
+buildSetupcfg rec {
+  info = import ./info.nix;
+  src = fetchFromGitHub {
+    owner = "target";
+    repo = "setupcfg2nix";
+    rev = info.version;
+    sha256 = "1zn9njpzwhwikrirgjlyz6ys3xr8gq61ry8blmnpscqvhsdhxcs6";
+  };
+  application = true;
+  meta = {
+    description = "Generate nix expressions from setup.cfg for a python package.";
+    homepage = https://github.com/target/setupcfg2nix;
+    license = lib.licenses.mit;
+    platforms = lib.platforms.all;
+    maintainers = [ lib.maintainers.shlevy ];
+  };
+}
diff --git a/pkgs/development/tools/setupcfg2nix/info.nix b/pkgs/development/tools/setupcfg2nix/info.nix
new file mode 100644
index 000000000000..b0d5873ed63c
--- /dev/null
+++ b/pkgs/development/tools/setupcfg2nix/info.nix
@@ -0,0 +1,7 @@
+{
+  pname = ''setupcfg2nix'';
+  version = ''1.1.0'';
+  install_requires = [
+    ''setuptools''
+  ];
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 199f6e878ff5..cdcabc0f51e0 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7230,6 +7230,8 @@ with pkgs;
     pythonPackages = python3Packages;
   };
 
+  setupcfg2nix = python3Packages.callPackage ../development/tools/setupcfg2nix {};
+
   # These pyside tools do not provide any Python modules and are meant to be here.
   # See ../development/python-modules/pyside/default.nix for details.
   pysideApiextractor = callPackage ../development/python-modules/pyside/apiextractor.nix { };
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index d7657ffc359d..80b1e63ecb87 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -66,6 +66,9 @@ let
     toPythonModule = x: x; # Application does not provide modules.
   }));
 
+  # See build-setupcfg/default.nix for documentation.
+  buildSetupcfg = import ../build-support/build-setupcfg self;
+
   graphiteVersion = "1.0.2";
 
   fetchPypi = makeOverridable( {format ? "setuptools", ... } @attrs:
@@ -133,6 +136,7 @@ in {
   inherit fetchPypi callPackage;
   inherit hasPythonModule requiredPythonModules makePythonPath disabledIf;
   inherit toPythonModule toPythonApplication;
+  inherit buildSetupcfg;
 
   # helpers