diff options
author | Vladimír Čunát <v@cunat.cz> | 2024-04-12 07:06:54 +0200 |
---|---|---|
committer | Vladimír Čunát <v@cunat.cz> | 2024-04-12 07:06:54 +0200 |
commit | 24d4f2cd52fc44f375e60ab4c90e159193689d72 (patch) | |
tree | 113c1984373abdd81ca189e25fa76396a55706bc /doc | |
parent | 4cfc319ea877f057cb7ad0c455c6af52e72bc557 (diff) | |
parent | 993400aeecf5ce185586dded2cebccebd628ec93 (diff) |
Merge branch 'staging' into staging-next
Conflicts (tried to quickly resolve somehow, checked eval):
pkgs/development/python-modules/apsw/default.nix
pkgs/development/python-modules/mido/default.nix
pkgs/development/python-modules/pytest-bdd/default.nix
pkgs/development/python-modules/sparse/default.nix
Diffstat (limited to 'doc')
-rw-r--r-- | doc/languages-frameworks/python.section.md | 76 |
1 files changed, 1 insertions, 75 deletions
diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index f325af0641f6..3b737333308d 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -497,40 +497,6 @@ are used in [`buildPythonPackage`](#buildpythonpackage-function). with the `pipInstallHook`. - `unittestCheckHook` will run tests with `python -m unittest discover`. See [example usage](#using-unittestcheckhook). -### Development mode {#development-mode} - -Development or editable mode is supported. To develop Python packages -[`buildPythonPackage`](#buildpythonpackage-function) has additional logic inside `shellPhase` to run `pip -install -e . --prefix $TMPDIR/`for the package. - -Warning: `shellPhase` is executed only if `setup.py` exists. - -Given a `default.nix`: - -```nix -with import <nixpkgs> {}; - -python3Packages.buildPythonPackage { - name = "myproject"; - buildInputs = with python3Packages; [ pyramid ]; - - src = ./.; -} -``` - -Running `nix-shell` with no arguments should give you the environment in which -the package would be built with `nix-build`. - -Shortcut to setup environments with C headers/libraries and Python packages: - -```shell -nix-shell -p python3Packages.pyramid zlib libjpeg git -``` - -::: {.note} -There is a boolean value `lib.inNixShell` set to `true` if nix-shell is invoked. -::: - ## User Guide {#user-guide} ### Using Python {#using-python} @@ -867,8 +833,7 @@ Above, we were mostly just focused on use cases and what to do to get started creating working Python environments in nix. Now that you know the basics to be up and running, it is time to take a step -back and take a deeper look at how Python packages are packaged on Nix. Then, -we will look at how you can use development mode with your code. +back and take a deeper look at how Python packages are packaged on Nix. #### Python library packages in Nixpkgs {#python-library-packages-in-nixpkgs} @@ -1481,45 +1446,6 @@ documentation source root. The hook is also available to packages outside the python ecosystem by referencing it using `sphinxHook` from top-level. -### Develop local package {#develop-local-package} - -As a Python developer you're likely aware of [development mode](http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode) -(`python setup.py develop`); instead of installing the package this command -creates a special link to the project code. That way, you can run updated code -without having to reinstall after each and every change you make. Development -mode is also available. Let's see how you can use it. - -In the previous Nix expression the source was fetched from a url. We can also -refer to a local source instead using `src = ./path/to/source/tree;` - -If we create a `shell.nix` file which calls [`buildPythonPackage`](#buildpythonpackage-function), and if `src` -is a local source, and if the local source has a `setup.py`, then development -mode is activated. - -In the following example, we create a simple environment that has a Python 3.11 -version of our package in it, as well as its dependencies and other packages we -like to have in the environment, all specified with `dependencies`. - -```nix -with import <nixpkgs> {}; -with python311Packages; - -buildPythonPackage rec { - name = "mypackage"; - src = ./path/to/package/source; - dependencies = [ - pytest - numpy - ]; - propagatedBuildInputs = [ - pkgs.libsndfile - ]; -} -``` - -It is important to note that due to how development mode is implemented on Nix -it is not possible to have multiple packages simultaneously in development mode. - ### Organising your packages {#organising-your-packages} So far we discussed how you can use Python on Nix, and how you can develop with |