doc/python: drop python2 references from manual section

Remove python27Packages, python2Packages, and pythonPackages alias
mentions; drop the "python refers to CPython 2.7" sentence and the
Python 2 namespace-collision note; strip Python-2-only inline comments
from the venvShellHook example.

Keep all pypy2/pypy27 references — pypy27 stays defined inside
pythonInterpreters as the bootstrap for pypy3.
This commit is contained in:
Aliaksandr
2026-05-04 16:56:39 +03:00
parent 34bc09dca9
commit aab86321db

View File

@@ -48,7 +48,6 @@ Based on the packages defined in `pkgs/top-level/python-packages.nix` an
attribute set is created for each available Python interpreter. The available
sets are
* `pkgs.python27Packages`
* `pkgs.python3Packages`
* `pkgs.python311Packages`
* `pkgs.python312Packages`
@@ -60,9 +59,7 @@ sets are
and the aliases
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
* `pkgs.python3Packages` pointing to `pkgs.python313Packages`
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
* `pkgs.pypy2Packages` pointing to `pkgs.pypy27Packages`
* `pkgs.pypy3Packages` pointing to `pkgs.pypy310Packages`
* `pkgs.pypyPackages` pointing to `pkgs.pypy2Packages`
@@ -573,9 +570,6 @@ In contrast to [`python.buildEnv`](#python.buildenv-function), [`python.withPack
more advanced options such as `ignoreCollisions = true` or `postBuild`. If you
need them, you have to use [`python.buildEnv`](#python.buildenv-function).
Python 2 namespace packages may provide `__init__.py` that collide. In that case
[`python.buildEnv`](#python.buildenv-function) should be used with `ignoreCollisions = true`.
#### Setup hooks {#setup-hooks}
The following are setup hooks specifically for Python packages. Most of these
@@ -627,10 +621,9 @@ buildPythonPackage.override { stdenv = customStdenv; } {
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
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
specific versions, e.g., `python313` refers to CPython 3.13, and `pypy` refers to
the default PyPy interpreter.
interpreter, which is currently CPython 3.13. It is also possible to refer to
specific versions, e.g., `python313` refers to CPython 3.13, and `pypy` refers
to the default PyPy interpreter.
Python is used a lot, and in different ways. This affects also how it is
packaged. In the case of Python on Nix, an important distinction is made between
@@ -1910,9 +1903,8 @@ pkgs.mkShell rec {
}
```
In case the supplied venvShellHook is insufficient, or when Python 2 support is
needed, you can define your own shell hook and adapt to your needs like in the
following example:
In case the supplied venvShellHook is insufficient, you can define your own
shell hook and adapt to your needs like in the following example:
```nix
with import <nixpkgs> { };
@@ -1925,8 +1917,6 @@ pkgs.mkShell rec {
name = "impurePythonEnv";
buildInputs = [
pythonPackages.python
# Needed when using python 2.7
# pythonPackages.virtualenv
# ...
];
@@ -1939,8 +1929,6 @@ pkgs.mkShell rec {
echo "Skipping venv creation, '${venvDir}' already exists"
else
echo "Creating new venv environment in path: '${venvDir}'"
# Note that the module venv was only introduced in python 3, so for 2.7
# this needs to be replaced with a call to virtualenv
${pythonPackages.python.interpreter} -m venv "${venvDir}"
fi