From 1986bedcffc8f378a8bfe90e8225c9d5fcf69883 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 25 Feb 2022 14:09:41 +0100 Subject: python3Packages: document how to handle extras-require --- doc/languages-frameworks/python.section.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'doc/languages-frameworks') diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 9f9ace513c3..693ea016e0a 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -979,6 +979,31 @@ with import {}; in python.withPackages(ps: [ps.blaze])).env ``` +#### Optional extra dependencies + +Some packages define optional dependencies for additional features. With +`setuptools` this is called `extras_require` and `flit` calls it `extras-require`. A +method for supporting this is by declaring the extras of a package in its +`passthru`, e.g. in case of the package `dask` + +```nix +passthru.extras-require = { + complete = [ distributed ]; +}; +``` + +and letting the package requiring the extra add the list to its dependencies + +```nix +propagatedBuildInputs = [ + ... +] ++ dask.extras-require.complete; +``` + +Note this method is preferred over adding parameters to builders, as that can +result in packages depending on different variants and thereby causing +collisions. + #### `buildPythonApplication` function {#buildpythonapplication-function} The `buildPythonApplication` function is practically the same as -- cgit 1.4.1