diff options
author | Yarny0 <41838844+Yarny0@users.noreply.github.com> | 2024-02-22 20:29:44 +0100 |
---|---|---|
committer | Yarny0 <41838844+Yarny0@users.noreply.github.com> | 2024-02-25 11:54:07 +0100 |
commit | e5d73251660f231dd15a14993d4042d9dc082c78 (patch) | |
tree | 7ee831cbb578164a053bcbe2acd62b399e493bfb /pkgs/development/interpreters | |
parent | 73de017ef2d18a04ac4bfd0c02650007ccb31c2a (diff) | |
download | nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar.gz nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar.bz2 nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar.lz nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar.xz nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.tar.zst nixlib-e5d73251660f231dd15a14993d4042d9dc082c78.zip |
pythonCatchConflictsHook: avoid infinite recursion
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 2651ddc7b0788932df9da7416ccd1618d76c11fe, 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.
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r-- | pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py b/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py index d4219192790b..ad679d9f9f99 100644 --- a/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py +++ b/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py @@ -57,7 +57,8 @@ def find_packages(store_path: Path, site_packages_path: str, parents: List[str]) with open(propagated_build_inputs, "r") as f: build_inputs: List[str] = f.read().strip().split(" ") for build_input in build_inputs: - find_packages(Path(build_input), site_packages_path, parents + [build_input]) + if build_input not in parents: + find_packages(Path(build_input), site_packages_path, parents + [build_input]) find_packages(out_path, site_packages_path, [f"this derivation: {out_path}"]) |