python3: 3.12.10 -> 3.13.3
Updates the default Python version to 3.13 for the NixOS 25.11 release cycle. We still keep recursing into python312Packages and python313Packages.
This commit is contained in:
@@ -61,7 +61,7 @@ sets are
|
|||||||
and the aliases
|
and the aliases
|
||||||
|
|
||||||
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
|
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
|
||||||
* `pkgs.python3Packages` pointing to `pkgs.python312Packages`
|
* `pkgs.python3Packages` pointing to `pkgs.python313Packages`
|
||||||
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
|
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
|
||||||
* `pkgs.pypy2Packages` pointing to `pkgs.pypy27Packages`
|
* `pkgs.pypy2Packages` pointing to `pkgs.pypy27Packages`
|
||||||
* `pkgs.pypy3Packages` pointing to `pkgs.pypy310Packages`
|
* `pkgs.pypy3Packages` pointing to `pkgs.pypy310Packages`
|
||||||
@@ -583,9 +583,9 @@ are used in [`buildPythonPackage`](#buildpythonpackage-function).
|
|||||||
|
|
||||||
Several versions of the Python interpreter are available on Nix, as well as a
|
Several versions of the Python interpreter are available on Nix, as well as a
|
||||||
high amount of packages. The attribute `python3` refers to the default
|
high amount of packages. The attribute `python3` refers to the default
|
||||||
interpreter, which is currently CPython 3.12. The attribute `python` refers to
|
interpreter, which is currently CPython 3.13. The attribute `python` refers to
|
||||||
CPython 2.7 for backwards-compatibility. It is also possible to refer to
|
CPython 2.7 for backwards-compatibility. It is also possible to refer to
|
||||||
specific versions, e.g. `python312` refers to CPython 3.12, and `pypy` refers to
|
specific versions, e.g. `python313` refers to CPython 3.13, and `pypy` refers to
|
||||||
the default PyPy interpreter.
|
the default PyPy interpreter.
|
||||||
|
|
||||||
Python is used a lot, and in different ways. This affects also how it is
|
Python is used a lot, and in different ways. This affects also how it is
|
||||||
@@ -601,10 +601,10 @@ however, are in separate sets, with one set per interpreter version.
|
|||||||
The interpreters have several common attributes. One of these attributes is
|
The interpreters have several common attributes. One of these attributes is
|
||||||
`pkgs`, which is a package set of Python libraries for this specific
|
`pkgs`, which is a package set of Python libraries for this specific
|
||||||
interpreter. E.g., the `toolz` package corresponding to the default interpreter
|
interpreter. E.g., the `toolz` package corresponding to the default interpreter
|
||||||
is `python3.pkgs.toolz`, and the CPython 3.12 version is `python312.pkgs.toolz`.
|
is `python3.pkgs.toolz`, and the CPython 3.13 version is `python313.pkgs.toolz`.
|
||||||
The main package set contains aliases to these package sets, e.g.
|
The main package set contains aliases to these package sets, e.g.
|
||||||
`pythonPackages` refers to `python.pkgs` and `python312Packages` to
|
`pythonPackages` refers to `python.pkgs` and `python313Packages` to
|
||||||
`python312.pkgs`.
|
`python313.pkgs`.
|
||||||
|
|
||||||
#### Installing Python and packages {#installing-python-and-packages}
|
#### Installing Python and packages {#installing-python-and-packages}
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ with [`python.buildEnv`](#python.buildenv-function) or [`python.withPackages`](#
|
|||||||
executables are wrapped to be able to find each other and all of the modules.
|
executables are wrapped to be able to find each other and all of the modules.
|
||||||
|
|
||||||
In the following examples we will start by creating a simple, ad-hoc environment
|
In the following examples we will start by creating a simple, ad-hoc environment
|
||||||
with a nix-shell that has `numpy` and `toolz` in Python 3.12; then we will create
|
with a nix-shell that has `numpy` and `toolz` in Python 3.13; then we will create
|
||||||
a re-usable environment in a single-file Python script; then we will create a
|
a re-usable environment in a single-file Python script; then we will create a
|
||||||
full Python environment for development with this same environment.
|
full Python environment for development with this same environment.
|
||||||
|
|
||||||
@@ -645,10 +645,10 @@ temporary shell session with a Python and a *precise* list of packages (plus
|
|||||||
their runtime dependencies), with no other Python packages in the Python
|
their runtime dependencies), with no other Python packages in the Python
|
||||||
interpreter's scope.
|
interpreter's scope.
|
||||||
|
|
||||||
To create a Python 3.12 session with `numpy` and `toolz` available, run:
|
To create a Python 3.13 session with `numpy` and `toolz` available, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p 'python312.withPackages(ps: with ps; [ numpy toolz ])'
|
$ nix-shell -p 'python313.withPackages(ps: with ps; [ numpy toolz ])'
|
||||||
```
|
```
|
||||||
|
|
||||||
By default `nix-shell` will start a `bash` session with this interpreter in our
|
By default `nix-shell` will start a `bash` session with this interpreter in our
|
||||||
@@ -656,7 +656,7 @@ By default `nix-shell` will start a `bash` session with this interpreter in our
|
|||||||
|
|
||||||
```Python console
|
```Python console
|
||||||
[nix-shell:~/src/nixpkgs]$ python3
|
[nix-shell:~/src/nixpkgs]$ python3
|
||||||
Python 3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 13.3.0] on linux
|
Python 3.13.3 (main, Apr 8 2025, 13:54:08) [GCC 14.2.1 20250322] on linux
|
||||||
Type "help", "copyright", "credits" or "license" for more information.
|
Type "help", "copyright", "credits" or "license" for more information.
|
||||||
>>> import numpy; import toolz
|
>>> import numpy; import toolz
|
||||||
```
|
```
|
||||||
@@ -676,8 +676,8 @@ will still get 1 wrapped Python interpreter. We can start the interpreter
|
|||||||
directly like so:
|
directly like so:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p "python312.withPackages (ps: with ps; [ numpy toolz requests ])" --run python3
|
$ nix-shell -p "python313.withPackages (ps: with ps; [ numpy toolz requests ])" --run python3
|
||||||
Python 3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 13.3.0] on linux
|
Python 3.13.3 (main, Apr 8 2025, 13:54:08) [GCC 14.2.1 20250322] on linux
|
||||||
Type "help", "copyright", "credits" or "license" for more information.
|
Type "help", "copyright", "credits" or "license" for more information.
|
||||||
>>> import requests
|
>>> import requests
|
||||||
>>>
|
>>>
|
||||||
@@ -717,7 +717,7 @@ Executing this script requires a `python3` that has `numpy`. Using what we learn
|
|||||||
in the previous section, we could startup a shell and just run it like so:
|
in the previous section, we could startup a shell and just run it like so:
|
||||||
|
|
||||||
```ShellSession
|
```ShellSession
|
||||||
$ nix-shell -p 'python312.withPackages (ps: with ps; [ numpy ])' --run 'python3 foo.py'
|
$ nix-shell -p 'python313.withPackages (ps: with ps; [ numpy ])' --run 'python3 foo.py'
|
||||||
The dot product of [1 2] and [3 4] is: 11
|
The dot product of [1 2] and [3 4] is: 11
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -780,12 +780,12 @@ create a single script with Python dependencies, but in the course of normal
|
|||||||
development we're usually working in an entire package repository.
|
development we're usually working in an entire package repository.
|
||||||
|
|
||||||
As explained [in the `nix-shell` section](https://nixos.org/manual/nix/stable/command-ref/nix-shell) of the Nix manual, `nix-shell` can also load an expression from a `.nix` file.
|
As explained [in the `nix-shell` section](https://nixos.org/manual/nix/stable/command-ref/nix-shell) of the Nix manual, `nix-shell` can also load an expression from a `.nix` file.
|
||||||
Say we want to have Python 3.12, `numpy` and `toolz`, like before,
|
Say we want to have Python 3.13, `numpy` and `toolz`, like before,
|
||||||
in an environment. We can add a `shell.nix` file describing our dependencies:
|
in an environment. We can add a `shell.nix` file describing our dependencies:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> { };
|
with import <nixpkgs> { };
|
||||||
(python312.withPackages (
|
(python313.withPackages (
|
||||||
ps: with ps; [
|
ps: with ps; [
|
||||||
numpy
|
numpy
|
||||||
toolz
|
toolz
|
||||||
@@ -804,7 +804,7 @@ What's happening here?
|
|||||||
imports the `<nixpkgs>` function, `{}` calls it and the `with` statement
|
imports the `<nixpkgs>` function, `{}` calls it and the `with` statement
|
||||||
brings all attributes of `nixpkgs` in the local scope. These attributes form
|
brings all attributes of `nixpkgs` in the local scope. These attributes form
|
||||||
the main package set.
|
the main package set.
|
||||||
2. Then we create a Python 3.12 environment with the [`withPackages`](#python.withpackages-function) function, as before.
|
2. Then we create a Python 3.13 environment with the [`withPackages`](#python.withpackages-function) function, as before.
|
||||||
3. The [`withPackages`](#python.withpackages-function) function expects us to provide a function as an argument
|
3. The [`withPackages`](#python.withpackages-function) function expects us to provide a function as an argument
|
||||||
that takes the set of all Python packages and returns a list of packages to
|
that takes the set of all Python packages and returns a list of packages to
|
||||||
include in the environment. Here, we select the packages `numpy` and `toolz`
|
include in the environment. Here, we select the packages `numpy` and `toolz`
|
||||||
@@ -815,7 +815,7 @@ To combine this with `mkShell` you can:
|
|||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> { };
|
with import <nixpkgs> { };
|
||||||
let
|
let
|
||||||
pythonEnv = python312.withPackages (ps: [
|
pythonEnv = python313.withPackages (ps: [
|
||||||
ps.numpy
|
ps.numpy
|
||||||
ps.toolz
|
ps.toolz
|
||||||
]);
|
]);
|
||||||
@@ -977,8 +977,8 @@ information. The output of the function is a derivation.
|
|||||||
|
|
||||||
An expression for `toolz` can be found in the Nixpkgs repository. As explained
|
An expression for `toolz` can be found in the Nixpkgs repository. As explained
|
||||||
in the introduction of this Python section, a derivation of `toolz` is available
|
in the introduction of this Python section, a derivation of `toolz` is available
|
||||||
for each interpreter version, e.g. `python312.pkgs.toolz` refers to the `toolz`
|
for each interpreter version, e.g. `python313.pkgs.toolz` refers to the `toolz`
|
||||||
derivation corresponding to the CPython 3.12 interpreter.
|
derivation corresponding to the CPython 3.13 interpreter.
|
||||||
|
|
||||||
The above example works when you're directly working on
|
The above example works when you're directly working on
|
||||||
`pkgs/top-level/python-packages.nix` in the Nixpkgs repository. Often though,
|
`pkgs/top-level/python-packages.nix` in the Nixpkgs repository. Often though,
|
||||||
@@ -992,7 +992,7 @@ with import <nixpkgs> { };
|
|||||||
|
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
my_toolz = python312.pkgs.buildPythonPackage rec {
|
my_toolz = python313.pkgs.buildPythonPackage rec {
|
||||||
pname = "toolz";
|
pname = "toolz";
|
||||||
version = "0.10.0";
|
version = "0.10.0";
|
||||||
pyproject = true;
|
pyproject = true;
|
||||||
@@ -1003,7 +1003,7 @@ with import <nixpkgs> { };
|
|||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [
|
||||||
python312.pkgs.setuptools
|
python313.pkgs.setuptools
|
||||||
];
|
];
|
||||||
|
|
||||||
# has no tests
|
# has no tests
|
||||||
@@ -1017,7 +1017,7 @@ with import <nixpkgs> { };
|
|||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
python312.withPackages (
|
python313.withPackages (
|
||||||
ps: with ps; [
|
ps: with ps; [
|
||||||
numpy
|
numpy
|
||||||
my_toolz
|
my_toolz
|
||||||
@@ -1027,7 +1027,7 @@ with import <nixpkgs> { };
|
|||||||
```
|
```
|
||||||
|
|
||||||
Executing `nix-shell` will result in an environment in which you can use
|
Executing `nix-shell` will result in an environment in which you can use
|
||||||
Python 3.12 and the `toolz` package. As you can see we had to explicitly mention
|
Python 3.13 and the `toolz` package. As you can see we had to explicitly mention
|
||||||
for which Python version we want to build a package.
|
for which Python version we want to build a package.
|
||||||
|
|
||||||
So, what did we do here? Well, we took the Nix expression that we used earlier
|
So, what did we do here? Well, we took the Nix expression that we used earlier
|
||||||
@@ -2130,7 +2130,7 @@ has security implications and is relevant for those using Python in a
|
|||||||
|
|
||||||
When the environment variable `DETERMINISTIC_BUILD` is set, all bytecode will
|
When the environment variable `DETERMINISTIC_BUILD` is set, all bytecode will
|
||||||
have timestamp 1. The [`buildPythonPackage`](#buildpythonpackage-function) function sets `DETERMINISTIC_BUILD=1`
|
have timestamp 1. The [`buildPythonPackage`](#buildpythonpackage-function) function sets `DETERMINISTIC_BUILD=1`
|
||||||
and [PYTHONHASHSEED=0](https://docs.python.org/3.12/using/cmdline.html#envvar-PYTHONHASHSEED).
|
and [PYTHONHASHSEED=0](https://docs.python.org/3.13/using/cmdline.html#envvar-PYTHONHASHSEED).
|
||||||
Both are also exported in `nix-shell`.
|
Both are also exported in `nix-shell`.
|
||||||
|
|
||||||
### How to provide automatic tests to Python packages? {#automatic-tests}
|
### How to provide automatic tests to Python packages? {#automatic-tests}
|
||||||
@@ -2179,10 +2179,10 @@ The following rules are desired to be respected:
|
|||||||
It does not need to be set explicitly unless the package requires a specific platform.
|
It does not need to be set explicitly unless the package requires a specific platform.
|
||||||
* The file is formatted with `nixfmt-rfc-style`.
|
* The file is formatted with `nixfmt-rfc-style`.
|
||||||
* Commit names of Python libraries must reflect that they are Python
|
* Commit names of Python libraries must reflect that they are Python
|
||||||
libraries (e.g. `python312Packages.numpy: 1.11 -> 1.12` rather than `numpy: 1.11 -> 1.12`).
|
libraries (e.g. `python313Packages.numpy: 1.11 -> 1.12` rather than `numpy: 1.11 -> 1.12`).
|
||||||
* The current default version of python should be included
|
* The current default version of python should be included
|
||||||
in commit messages to enable automatic builds by ofborg.
|
in commit messages to enable automatic builds by ofborg.
|
||||||
For example `python312Packages.numpy: 1.11 -> 1.12` should be used rather
|
For example `python313Packages.numpy: 1.11 -> 1.12` should be used rather
|
||||||
than `python3Packages.numpy: 1.11 -> 1.12`.
|
than `python3Packages.numpy: 1.11 -> 1.12`.
|
||||||
Note that `pythonPackages` is an alias for `python27Packages`.
|
Note that `pythonPackages` is an alias for `python27Packages`.
|
||||||
* Attribute names in `python-packages.nix` as well as `pname`s should match the
|
* Attribute names in `python-packages.nix` as well as `pname`s should match the
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
passthruFun = import ./passthrufun.nix args;
|
passthruFun = import ./passthrufun.nix args;
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
python312 = {
|
python313 = {
|
||||||
sourceVersion = {
|
sourceVersion = {
|
||||||
major = "3";
|
major = "3";
|
||||||
minor = "12";
|
minor = "13";
|
||||||
patch = "10";
|
patch = "3";
|
||||||
suffix = "";
|
suffix = "";
|
||||||
};
|
};
|
||||||
hash = "sha256-B6tpdHRZXgbwZkdBfTx/qX3tB6/Bp+RFTFY5kZtG6uo=";
|
hash = "sha256-QPhovL3rgUmjFJWAu5v9QHszIc1I8L5jGvlVrJLA4EE=";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,26 +67,26 @@
|
|||||||
inherit passthruFun;
|
inherit passthruFun;
|
||||||
};
|
};
|
||||||
|
|
||||||
python312 = callPackage ./cpython (
|
python312 = callPackage ./cpython {
|
||||||
{
|
|
||||||
self = __splicedPackages.python312;
|
self = __splicedPackages.python312;
|
||||||
inherit passthruFun;
|
|
||||||
}
|
|
||||||
// sources.python312
|
|
||||||
);
|
|
||||||
|
|
||||||
python313 = callPackage ./cpython {
|
|
||||||
self = __splicedPackages.python313;
|
|
||||||
sourceVersion = {
|
sourceVersion = {
|
||||||
major = "3";
|
major = "3";
|
||||||
minor = "13";
|
minor = "12";
|
||||||
patch = "3";
|
patch = "10";
|
||||||
suffix = "";
|
suffix = "";
|
||||||
};
|
};
|
||||||
hash = "sha256-QPhovL3rgUmjFJWAu5v9QHszIc1I8L5jGvlVrJLA4EE=";
|
hash = "sha256-B6tpdHRZXgbwZkdBfTx/qX3tB6/Bp+RFTFY5kZtG6uo=";
|
||||||
inherit passthruFun;
|
inherit passthruFun;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
python313 = callPackage ./cpython (
|
||||||
|
{
|
||||||
|
self = __splicedPackages.python313;
|
||||||
|
inherit passthruFun;
|
||||||
|
}
|
||||||
|
// sources.python313
|
||||||
|
);
|
||||||
|
|
||||||
python314 = callPackage ./cpython {
|
python314 = callPackage ./cpython {
|
||||||
self = __splicedPackages.python314;
|
self = __splicedPackages.python314;
|
||||||
sourceVersion = {
|
sourceVersion = {
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
"libffi"
|
"libffi"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// sources.python312
|
// sources.python313
|
||||||
)).overrideAttrs
|
)).overrideAttrs
|
||||||
(old: {
|
(old: {
|
||||||
# TODO(@Artturin): Add this to the main cpython expr
|
# TODO(@Artturin): Add this to the main cpython expr
|
||||||
|
|||||||
@@ -6531,11 +6531,11 @@ with pkgs;
|
|||||||
# available as `pythonPackages.tkinter` and can be used as any other Python package.
|
# available as `pythonPackages.tkinter` and can be used as any other Python package.
|
||||||
# When switching these sets, please update docs at ../../doc/languages-frameworks/python.md
|
# When switching these sets, please update docs at ../../doc/languages-frameworks/python.md
|
||||||
python2 = python27;
|
python2 = python27;
|
||||||
python3 = python312;
|
python3 = python313;
|
||||||
|
|
||||||
# pythonPackages further below, but assigned here because they need to be in sync
|
# pythonPackages further below, but assigned here because they need to be in sync
|
||||||
python2Packages = dontRecurseIntoAttrs python27Packages;
|
python2Packages = dontRecurseIntoAttrs python27Packages;
|
||||||
python3Packages = dontRecurseIntoAttrs python312Packages;
|
python3Packages = dontRecurseIntoAttrs python313Packages;
|
||||||
|
|
||||||
pypy = pypy2;
|
pypy = pypy2;
|
||||||
pypy2 = pypy27;
|
pypy2 = pypy27;
|
||||||
|
|||||||
Reference in New Issue
Block a user