From 2270b66d759f0a9c022576ce42fa5a770a754250 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 20 Jul 2022 08:45:47 +0200 Subject: pythonPackagesExtensions: override all Python package sets at once Python package sets can be overridden by overriding an interpreter and passing in `packageOverrides = self: super: {...};`. This is fine in case you need a single interpreter, however, it does not help you when you want to override all sets. With this change it is possible to override all sets at once by appending a list of "extensions" to `pythonPackagesExtensions`. From reading the implementation you might wonder why a list is used, and not `lib.composeExtensions`? The reason is the latter requires knowledge of the library function. This approach should be easier for most users as it is similar to how we append to lists of e.g. inputs or patches when overriding a derivation. --- doc/languages-frameworks/python.section.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc/languages-frameworks/python.section.md') diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 7df8464917cf..7fb8ba2e7c27 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -1664,6 +1664,26 @@ self: super: { } ``` +### How to override a Python package for all Python versions using extensions? {#how-to-override-a-python-package-for-all-python-versions-using-extensions} + +The following overlay overrides the call to `buildPythonPackage` for the +`foo` package for all interpreters by appending a Python extension to the +`pythonPackagesExtensions` list of extensions. + +```nix +final: prev: { + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + ( + python-final: python-prev: { + foo = python-prev.foo.overridePythonAttrs (oldAttrs: { + ... + }); + } + ) + ]; +} +``` + ### How to use Intel’s MKL with numpy and scipy? {#how-to-use-intels-mkl-with-numpy-and-scipy} MKL can be configured using an overlay. See the section "[Using overlays to -- cgit 1.4.1