diff options
Diffstat (limited to 'doc/languages-frameworks/python.md')
-rw-r--r-- | doc/languages-frameworks/python.md | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md index dd9af4e827e2..99fb6774b82b 100644 --- a/doc/languages-frameworks/python.md +++ b/doc/languages-frameworks/python.md @@ -532,6 +532,7 @@ All parameters from `mkDerivation` function are still supported. * `makeWrapperArgs`: A list of strings. Arguments to be passed to `makeWrapper`, which wraps generated binaries. By default, the arguments to `makeWrapper` set `PATH` and `PYTHONPATH` environment variables before calling the binary. Additional arguments here can allow a developer to set environment variables which will be available when the binary is run. For example, `makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`. * `installFlags`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]. * `format`: Format of the source. Options are `setup` for when the source has a `setup.py` and `setuptools` is used to build a wheel, and `wheel` in case the source is already a binary wheel. The default value is `setup`. +* `catchConflicts` If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. #### `buildPythonApplication` function @@ -648,6 +649,56 @@ community to help save time. No tool is preferred at the moment. ## FAQ +### How can I install a working Python environment? + +As explained in the user's guide installing individual Python packages +imperatively with `nix-env -i` or declaratively in `environment.systemPackages` +is not supported. However, it is possible to install a Python environment with packages (`python.buildEnv`). + +In the following examples we create an environment with Python 3.5, `numpy` and `ipython`. +As you might imagine there is one limitation here, and that's you can install +only one environment at a time. You will notice the complaints about collisions +when you try to install a second environment. + +#### Environment defined in separate `.nix` file + +Create a file, e.g. `build.nix`, with the following expression +```nix +with import <nixpkgs> {}; +with python35Packages; + +python.withPackages (ps: with ps; [ numpy ipython ]) +``` +and install it in your profile with +``` +nix-env -if build.nix +``` +Now you can use the Python interpreter, as well as the extra packages that you added to the environment. + +#### Environment defined in `~/.nixpkgs/config.nix` + +If you prefer to, you could also add the environment as a package override to the Nixpkgs set. +``` + packageOverrides = pkgs: with pkgs; with python35Packages; { + myEnv = python.withPackages (ps: with ps; [ numpy ipython ]); + }; +``` +and install it in your profile with +``` +nix-env -iA nixos.blogEnv +``` +Note that I'm using the attribute path here. + +#### Environment defined in `/etc/nixos/configuration.nix` + +For the sake of completeness, here's another example how to install the environment system-wide. + +```nix +environment.systemPackages = with pkgs; [ + (python35Packages.python.withPackages (ps: callPackage ../packages/common-python-packages.nix { pythonPackages = ps; })) +]; +``` + ### How to solve circular dependencies? Consider the packages `A` and `B` that depend on each other. When packaging `B`, |