Much like the previous commit that adds dependencies &
optional-dependencies this aligns PEP-517 build systems with how they
are defined in PEP-518/PEP-621.
The naming `build-system` (singular) is aligned with upstream Python standards.
Since https://github.com/NixOS/nixpkgs/pull/161835 we've had the
concept of `passthru.optional-dependencies` for Python optional deps.
Having to explicitly put optional-dependencies in the passthru attrset
is a bit strange API-wise, even though it semantically makes sense.
This change unifies the handling of non-optional & optional Python
dependencies using the names established from PEP-621 (standardized pyproject.toml project metadata).
This changes the non-legacy version of pythonCatchConflictsHook
to recursively scan the output of the target derivation as well
as its propagatedBuildInputs for duplicate dependencies.
Previously, we did scan sys.path but did prove problematic as it
produced false positives i.e. when build-time dependencies of
hooks - such as setuptools in pythonCatchConflictsHook itself -
where mistakenly flagged as duplicates; even though the are
not included in the outputs of the target dervation.
As all python runtime-dependencies are currently passed via
propagatedBuildInputs in nixpkgs, scanning that plus
site-packages seems sufficient to catch all conflicts that
matter at runtime and less likely to produce false positives.
The legacyHook in catch_conflicts_py2.py needs to be migrated
as well, if it's still needed.
Without the change `test-pythonPackagesExtensions` test fails the eval
as:
$ nix build -f. pythonInterpreters.pypy39_prebuilt.tests --show-trace
error:
… while evaluating an attribute name
at pkgs/development/interpreters/python/tests.nix:151:16:
150| });
151| in pkgs_.${python.pythonAttr}.pkgs.foo;
| ^
152| });
error: value is null while a string was expected
This happens because `pypy39_prebuilt` exposes `pythonAttr` attribute,
but it has a `null` value. Fix the test to filter out prebuilt pypy.
Without the change the eval fails as:
$ nix build --no-link -f. pythonInterpreters.pypy39_prebuilt.buildEnv
error:
error: attribute 'pypy38_prebuilt' missing
208| # Not included at top-level
209| self = __splicedPackages.pythonInterpreters.pypy38_prebuilt;
| ^
210| sourceVersion = {
Did you mean one of pypy39_prebuilt or pypy27_prebuilt?
Is it PyOpenSSL or pyOpenSSL or pyopenssl? With this change you don't
have to care. Write it as pYoPeNSsL for all I care¹.
Can we do it like that? Yes, we can. Distribution names should be matched
with `re.IGNORECASE` according to the wheel specification².
[1] https://packaging.python.org/en/latest/specifications/core-metadata/#name
[2] Just kidding, please make it look sane.
Implements a hook, that checks whether all dependencies, as specified by
the wheel manifest, are present in the current environment.
Complains about missing packages, as well as version specifier
mismatches.
This function is not, and never have been, used anywhere inside nixpkgs, outside of bootstrapping setupcfg2nix itself.
It was added in https://github.com/NixOS/nixpkgs/pull/38778 by @shlevy.
It has no out-of-tree users on Github either. External breakage is not expected.
f292ef4 introduced a check for the Python version but uses `.version`,
which isn't friendly to other Pythons like PyPy which use versions
strings like 7.3, failing the >=3.10 check.
Using `.pythonVersion` fixes this check.
Co-authored-by: Pierre Bourdon <delroth@gmail.com>
By restoring and diverting to the old version.
Previously the newer language features and use of more modern stdlib
imports broke the hook on Python<3.10.
We need this stuff to be available in lib so make-derivation.nix can
access it to construct the Meson cross file.
This has a couple of other advantages:
- It makes Rust less special. Now figuring out what Rust calls a
platform is the same as figuring out what Linux or QEMU call it.
- We can unify the schema used to define Rust targets, and the schema
used to access those values later. Just like you can set "config"
or "system" in a platform definition, and then access those same
keys on the elaborated platform, you can now set "rustcTarget" in
your crossSystem, and then access "stdenv.hostPlatform.rustcTarget"
in your code.
"rustcTarget", "rustcTargetSpec", "cargoShortTarget", and
"cargoEnvVarTarget" have the "rustc" and "cargo" prefixes because
these are not exposed to code by the compiler, and are not
standardized. The arch/os/etc. variables are all named to match the
forms in the Rust target spec JSON.
The new rust.target-family only takes a list, since we don't need to
worry about backwards compatibility when that name is used.
The old APIs are all still functional with no warning for now, so that
it's possible for external code to use a single API on both 23.05 and
23.11. We can introduce the warnings once 23.05 is EOL, and make them
hard errors when 23.11 is EOL.
To escape the pkg_resources API deprecation:
> catch-conflicts.py:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
Also remove exceptions for the previus bootstrap packages.
With this change it is possible to pass in `stdenv` directly to
`buildPython*` or override it using e.g.
```
numpy.overridePythonAttrs(_: {
stdenv = clangStdenv;
})
```
The situation:
Python <3.11: under Linux the abi string is always -gnu*
Python 3.11-3.12: musl is treated as its own abi in the python build system, but when cross-compiling the build host's libc is used for the target abi string. Cross compiling from glibc to musl gives a -gnu* target abi string and vice versa.
Python >=3.13: musl is treated as its own abi, and when cross-compiling the target libc is used for the target abi string
We backport the fix for python 3.11-3.12, since the intermediate state is almost impossible to model in the nix expression