@@ -9,7 +9,7 @@
99Several versions of the Python interpreter are available on Nix, as well as a
1010high amount of packages. The attribute `python` refers to the default
1111interpreter, which is currently CPython 2.7. It is also possible to refer to
12−specific versions, e.g. `python35` refers to CPython 3.5, and `pypy` refers to
12+specific versions, e.g. `python38` refers to CPython 3.8, and `pypy` refers to
1313the default PyPy interpreter.
1414
1515Python is used a lot, and in different ways. This affects also how it is
@@ -25,10 +25,10 @@ however, are in separate sets, with one set per interpreter version.
2525The interpreters have several common attributes. One of these attributes is
2626`pkgs`, which is a package set of Python libraries for this specific
2727interpreter. E.g., the `toolz` package corresponding to the default interpreter
28−is `python.pkgs.toolz`, and the CPython 3.5 version is `python35.pkgs.toolz`.
28+is `python.pkgs.toolz`, and the CPython 3.8 version is `python38.pkgs.toolz`.
2929The main package set contains aliases to these package sets, e.g.
30−`pythonPackages` refers to `python.pkgs` and `python35Packages` to
31−`python35.pkgs`.
30+`pythonPackages` refers to `python.pkgs` and `python38Packages` to
31+`python38.pkgs`.
3232
3333#### Installing Python and packages
3434
@@ -50,7 +50,7 @@ to create an environment with `python.buildEnv` or `python.withPackages` where
5050the interpreter and other executables are able to find each other and all of the
5151modules.
5252
53−In the following examples we create an environment with Python 3.5, `numpy` and
53+In the following examples we create an environment with Python 3.8, `numpy` and
5454`toolz`. As you may imagine, there is one limitation here, and that's that
5555you can install only one environment at a time. You will notice the complaints
5656about collisions when you try to install a second environment.
@@ -61,7 +61,7 @@ Create a file, e.g. `build.nix`, with the following expression
6161```nix
6262with import <nixpkgs> {};
6363
64−python35.withPackages (ps: with ps; [ numpy toolz ])
64+python38.withPackages (ps: with ps; [ numpy toolz ])
6565```
6666and install it in your profile with
6767```shell
@@ -79,7 +79,7 @@ Nixpkgs set, e.g. using `config.nix`,
7979{ # ...
8080
8181 packageOverrides = pkgs: with pkgs; {
82− myEnv = python35.withPackages (ps: with ps; [ numpy toolz ]);
82+ myEnv = python38.withPackages (ps: with ps; [ numpy toolz ]);
8383 };
8484}
8585```
@@ -101,7 +101,7 @@ environment system-wide.
101101{ # ...
102102
103103 environment.systemPackages = with pkgs; [
104− (python35.withPackages(ps: with ps; [ numpy toolz ]))
104+ (python38.withPackages(ps: with ps; [ numpy toolz ]))
105105 ];
106106}
107107```
@@ -118,7 +118,7 @@ recommended method is to create an environment with `python.buildEnv` or
118118`python.withPackages` and load that. E.g.
119119
120120```sh
121−$ nix-shell -p 'python35.withPackages(ps: with ps; [ numpy toolz ])'
121+$ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy toolz ])'
122122```
123123
124124opens a shell from which you can launch the interpreter
@@ -131,7 +131,7 @@ The other method, which is not recommended, does not create an environment and
131131requires you to list the packages directly,
132132
133133```sh
134−$ nix-shell -p python35.pkgs.numpy python35.pkgs.toolz
134+$ nix-shell -p python38.pkgs.numpy python38.pkgs.toolz
135135```
136136
137137Again, it is possible to launch the interpreter from the shell. The Python
@@ -140,14 +140,14 @@ that specific interpreter.
140140
141141##### Load environment from `.nix` expression
142142As explained in the Nix manual, `nix-shell` can also load an
143−expression from a `.nix` file. Say we want to have Python 3.5, `numpy`
143+expression from a `.nix` file. Say we want to have Python 3.8, `numpy`
144144and `toolz`, like before, in an environment. Consider a `shell.nix` file
145145with
146146
147147```nix
148148with import <nixpkgs> {};
149149
150−(python35.withPackages (ps: [ps.numpy ps.toolz])).env
150+(python38.withPackages (ps: [ps.numpy ps.toolz])).env
151151```
152152
153153Executing `nix-shell` gives you again a Nix shell from which you can run Python.
@@ -158,7 +158,7 @@ What's happening here?
158158 imports the `<nixpkgs>` function, `{}` calls it and the `with` statement
159159 brings all attributes of `nixpkgs` in the local scope. These attributes form
160160 the main package set.
161−2. Then we create a Python 3.5 environment with the `withPackages` function.
161+2. Then we create a Python 3.8 environment with the `withPackages` function.
1621623. The `withPackages` function expects us to provide a function as an argument
163163 that takes the set of all python packages and returns a list of packages to
164164 include in the environment. Here, we select the packages `numpy` and `toolz`
@@ -170,7 +170,7 @@ To combine this with `mkShell` you can:
170170with import <nixpkgs> {};
171171
172172let
173− pythonEnv = python35.withPackages (ps: [
173+ pythonEnv = python38.withPackages (ps: [
174174 ps.numpy
175175 ps.toolz
176176 ]);
@@ -188,13 +188,13 @@ option, with which you can execute a command in the `nix-shell`. We can
188188e.g. directly open a Python shell
189189
190190```sh
191−$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3"
191+$ nix-shell -p python38Packages.numpy python38Packages.toolz --run "python3"
192192```
193193
194194or run a script
195195
196196```sh
197−$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3 myscript.py"
197+$ nix-shell -p python38Packages.numpy python38Packages.toolz --run "python3 myscript.py"
198198```
199199
200200##### `nix-shell` as shebang
@@ -231,11 +231,11 @@ building Python libraries is `buildPythonPackage`. Let's see how we can build th
231231
232232buildPythonPackage rec {
233233 pname = "toolz";
234− version = "0.7.4";
234+ version = "0.10.0";
235235
236236 src = fetchPypi {
237237 inherit pname version;
238− sha256 = "43c2c9e5e7a16b6c88ba3088a9bfc82f7db8e13378be7c78d6c14a5f8ed05afd";
238+ sha256 = "08fdd5ef7c96480ad11c12d472de21acd32359996f69a5259299b540feba4560";
239239 };
240240
241241 doCheck = false;
@@ -260,8 +260,8 @@ information. The output of the function is a derivation.
260260
261261An expression for `toolz` can be found in the Nixpkgs repository. As explained
262262in the introduction of this Python section, a derivation of `toolz` is available
263−for each interpreter version, e.g. `python35.pkgs.toolz` refers to the `toolz`
264−derivation corresponding to the CPython 3.5 interpreter.
263+for each interpreter version, e.g. `python38.pkgs.toolz` refers to the `toolz`
264+derivation corresponding to the CPython 3.8 interpreter.
265265The above example works when you're directly working on
266266`pkgs/top-level/python-packages.nix` in the Nixpkgs repository. Often though,
267267you will want to test a Nix expression outside of the Nixpkgs tree.
@@ -273,13 +273,13 @@ and adds it along with a `numpy` package to a Python environment.
273273with import <nixpkgs> {};
274274
275275( let
276− my_toolz = python35.pkgs.buildPythonPackage rec {
276+ my_toolz = python38.pkgs.buildPythonPackage rec {
277277 pname = "toolz";
278− version = "0.7.4";
278+ version = "0.10.0";
279279
280− src = python35.pkgs.fetchPypi {
280+ src = python38.pkgs.fetchPypi {
281281 inherit pname version;
282− sha256 = "43c2c9e5e7a16b6c88ba3088a9bfc82f7db8e13378be7c78d6c14a5f8ed05afd";
282+ sha256 = "08fdd5ef7c96480ad11c12d472de21acd32359996f69a5259299b540feba4560";
283283 };
284284
285285 doCheck = false;
@@ -290,12 +290,12 @@ with import <nixpkgs> {};
290290 };
291291 };
292292
293− in python35.withPackages (ps: [ps.numpy my_toolz])
293+ in python38.withPackages (ps: [ps.numpy my_toolz])
294294).env
295295```
296296
297297Executing `nix-shell` will result in an environment in which you can use
298−Python 3.5 and the `toolz` package. As you can see we had to explicitly mention
298+Python 3.8 and the `toolz` package. As you can see we had to explicitly mention
299299for which Python version we want to build a package.
300300
301301So, what did we do here? Well, we took the Nix expression that we used earlier
@@ -435,7 +435,7 @@ If we create a `shell.nix` file which calls `buildPythonPackage`, and if `src`
435435is a local source, and if the local source has a `setup.py`, then development
436436mode is activated.
437437
438−In the following example we create a simple environment that has a Python 3.5
438+In the following example we create a simple environment that has a Python 3.8
439439version of our package in it, as well as its dependencies and other packages we
440440like to have in the environment, all specified with `propagatedBuildInputs`.
441441Indeed, we can just add any package we like to have in our environment to
@@ -443,7 +443,7 @@ Indeed, we can just add any package we like to have in our environment to
443443
444444```nix
445445with import <nixpkgs> {};
446−with python35Packages;
446+with python38Packages;
447447
448448buildPythonPackage rec {
449449 name = "mypackage";
@@ -505,9 +505,9 @@ with import <nixpkgs> {};
505505
506506( let
507507 toolz = callPackage /path/to/toolz/release.nix {
508− buildPythonPackage = python35Packages.buildPythonPackage;
508+ buildPythonPackage = python38Packages.buildPythonPackage;
509509 };
510− in python35.withPackages (ps: [ ps.numpy toolz ])
510+ in python38.withPackages (ps: [ ps.numpy toolz ])
511511).env
512512```
513513
@@ -515,8 +515,8 @@ Important to remember is that the Python version for which the package is made
515515depends on the `python` derivation that is passed to `buildPythonPackage`. Nix
516516tries to automatically pass arguments when possible, which is why generally you
517517don't explicitly define which `python` derivation should be used. In the above
518−example we use `buildPythonPackage` that is part of the set `python35Packages`,
519−and in this case the `python35` interpreter is automatically used.
518+example we use `buildPythonPackage` that is part of the set `python38Packages`,
519+and in this case the `python38` interpreter is automatically used.
520520
521521## Reference
522522
@@ -662,7 +662,7 @@ following are specific to `buildPythonPackage`:
662662 variables which will be available when the binary is run. For example,
663663 `makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`.
664664* `namePrefix`: Prepends text to `${name}` parameter. In case of libraries, this
665− defaults to `"python3.5-"` for Python 3.5, etc., and in case of applications
665+ defaults to `"python3.8-"` for Python 3.8, etc., and in case of applications
666666 to `""`.
667667* `pythonPath ? []`: List of packages to be added into `$PYTHONPATH`. Packages
668668 in `pythonPath` are not propagated (contrary to `propagatedBuildInputs`).
@@ -960,7 +960,7 @@ has security implications and is relevant for those using Python in a
960960
961961When the environment variable `DETERMINISTIC_BUILD` is set, all bytecode will
962962have timestamp 1. The `buildPythonPackage` function sets `DETERMINISTIC_BUILD=1`
963−and [PYTHONHASHSEED=0](https://docs.python.org/3.5/using/cmdline.html#envvar-PYTHONHASHSEED).
963+and [PYTHONHASHSEED=0](https://docs.python.org/3.8/using/cmdline.html#envvar-PYTHONHASHSEED).
964964Both are also exported in `nix-shell`.
965965
966966
@@ -1014,7 +1014,7 @@ with import <nixpkgs> {};
10141014 packageOverrides = self: super: {
10151015 pandas = super.pandas.overridePythonAttrs(old: {name="foo";});
10161016 };
1017− in pkgs.python35.override {inherit packageOverrides;};
1017+ in pkgs.python38.override {inherit packageOverrides;};
10181018
10191019in python.withPackages(ps: [ps.pandas])).env
10201020```
@@ -1036,7 +1036,7 @@ with import <nixpkgs> {};
10361036 packageOverrides = self: super: {
10371037 scipy = super.scipy_0_17;
10381038 };
1039− in (pkgs.python35.override {inherit packageOverrides;}).withPackages (ps: [ps.blaze])
1039+ in (pkgs.python38.override {inherit packageOverrides;}).withPackages (ps: [ps.blaze])
10401040).env
10411041```
10421042
@@ -1049,12 +1049,12 @@ If you want the whole of Nixpkgs to use your modifications, then you can use
10491049```nix
10501050let
10511051 pkgs = import <nixpkgs> {};
1052− newpkgs = import pkgs.path { overlays = [ (pkgsself: pkgssuper: {
1053− python27 = let
1054− packageOverrides = self: super: {
1055− numpy = super.numpy_1_10;
1052+ newpkgs = import pkgs.path { overlays = [ (self: super: {
1053+ python38 = let
1054+ packageOverrides = python-self: python-super: {
1055+ numpy = python-super.numpy_1_18.3;
10561056 };
1057− in pkgssuper.python27.override {inherit packageOverrides;};
1057+ in super.python38.override {inherit packageOverrides;};
10581058 } ) ]; };
10591059in newpkgs.inkscape
10601060```