Albeit counter-intutive, the `propagatedBuildInputs`
mechanism and the corresponding package files in
`nix-support/propagated-build-inputs`
can form a dependency cycle.
This can happen if a package adds itself to this file,
or if multiple outputs of one derivation reference each other.
An example for this is the `patchPpdFilesHook`:
In its mission to collect dependency packages with binaries
that might be required by the dependent package to be created,
it sometimes picks up the dependent package itself.
This indicates that if a file of the dependent package
is used, the package itself should also be installed.
In the case of a multiple output package,
it is also possible that two outputs depend on each other,
creating a dependency cycle.
Since commit 2651ddc7b0,
the `find_packages` function in `catch_conflicts.py`
recursively collects all `propagated-build-inputs` files.
If it encounters a dependency cycle, it must not follow the
cycle to avoid infinite recursion (and a stack overflow).
The commit at hand adds a check so that the function skips over
a package that it already encountered and processed earlier.
This does not loosen the script's checks as the script
still recursively collects all propagated build inputs.
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.