about summary refs log tree commit diff
path: root/pkgs/build-support/build-setupcfg
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-04-11 12:02:06 -0400
committerShea Levy <shea@shealevy.com>2018-04-11 12:08:26 -0400
commit0901b3e195834269902b0979b49b9772c447ed08 (patch)
treea3201666fcc5b87d04539e72de2244749d8b96bb /pkgs/build-support/build-setupcfg
parent9b8668c79c5dc4f0df14d13d2ea32f522737acd4 (diff)
Add setupcfg2nix and supporting infrastructure
Diffstat (limited to 'pkgs/build-support/build-setupcfg')
-rw-r--r--pkgs/build-support/build-setupcfg/default.nix23
1 files changed, 23 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 0000000000000..62dda59f1d527
--- /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 []);
+}