summary refs log tree commit diff
path: root/doc/languages-frameworks/python.section.md
diff options
context:
space:
mode:
authorDoron Behar <doron.behar@gmail.com>2023-07-12 15:17:32 +0300
committerMartin Weinelt <hexa@darmstadt.ccc.de>2023-07-28 12:13:25 +0200
commit5262a7d1c9c81d86fb8c75104fd16f2c7b868aee (patch)
treecddaf5e5d227bf80124ab71792f07a600c25ec87 /doc/languages-frameworks/python.section.md
parent8e5efa270ff4d360d9a106e49d3b46b3c5395c58 (diff)
downloadnixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar.gz
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar.bz2
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar.lz
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar.xz
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.tar.zst
nixpkgs-5262a7d1c9c81d86fb8c75104fd16f2c7b868aee.zip
doc/python: Demonstrate how to override the blas implementation
Diffstat (limited to 'doc/languages-frameworks/python.section.md')
-rw-r--r--doc/languages-frameworks/python.section.md24
1 files changed, 22 insertions, 2 deletions
diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md
index 947ce602865..a66113db516 100644
--- a/doc/languages-frameworks/python.section.md
+++ b/doc/languages-frameworks/python.section.md
@@ -1185,8 +1185,7 @@ following are specific to `buildPythonPackage`:
   variables which will be available when the binary is run. For example,
   `makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`.
 * `namePrefix`: Prepends text to `${name}` parameter. In case of libraries, this
-  defaults to `"python3.8-"` for Python 3.8, etc., and in case of applications
-  to `""`.
+  defaults to `"python3.8-"` for Python 3.8, etc., and in case of applications to `""`.
 * `pipInstallFlags ? []`: A list of strings. Arguments to be passed to `pip
   install`. To pass options to `python setup.py install`, use
   `--install-option`. E.g., `pipInstallFlags=["--install-option='--cpp_implementation'"]`.
@@ -1244,6 +1243,27 @@ with import <nixpkgs> {};
 in python.withPackages(ps: [ ps.blaze ])).env
 ```
 
+The next example shows a non trivial overriding of the `blas` implementation to
+be used through out all of the Python package set:
+
+```nix
+python3MyBlas = pkgs.python3.override {
+  packageOverrides = self: super: {
+    # We need toPythonModule for the package set to evaluate this
+    blas = super.toPythonModule(super.pkgs.blas.override {
+      blasProvider = super.pkgs.mkl;
+    });
+    lapack = super.toPythonModule(super.pkgs.lapack.override {
+      lapackProvider = super.pkgs.mkl;
+    });
+  };
+};
+```
+
+This is particularly useful for numpy and scipy users who want to gain speed with other blas implementations.
+Note that using simply `scipy = super.scipy.override { blas = super.pkgs.mkl; };` will likely result in
+compilation issues, because scipy dependencies need to use the same blas implementation as well.
+
 #### Optional extra dependencies {#python-optional-dependencies}
 
 Some packages define optional dependencies for additional features. With