-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The problem
The documentation of check_reqs says:
Check if the given requirements are all satisfied.
[...]
[Returns:] All the requirements inreqssatisfied or not.
But in reality, it only checks transitive ("nested") dependencies if they're part of a top-level extra or its extras, recursively.
To reproduce
To convince yourself that this is the case, you can:
- Install
typer-slim[standard]==0.12.5.- This depends on
richfor thestandardextra, whilerichin turn depends onPygmentsunconditionally.
- This depends on
- Uninstall
Pygmentsmanually with Pip, leavingrichitself installed but with broken dependencies. - Notice that
check_reqs("typer-slim[standard]")still returnsTrue. - Optional sanity check: Uninstall
rich, which will causecheck_reqs("typer-slim[standard]")to correctly returnFalse(because its direct dependent is thestandardextra oftyper-slim).
Comparison to "reference" library
This is different from the behavior of e.g. pkg_resources.require, which checks all dependencies recursively whether they're part of an extra or not.
Cause in the code
The code section that causes this to happen:
hbutils/hbutils/system/python/package.py
Lines 184 to 192 in 927b075
| need_check, ext = False, None | |
| for extra in req.extras: | |
| if child_req_obj.marker and child_req_obj.marker.evaluate({'extra': extra}): | |
| need_check = True | |
| ext = extra | |
| break | |
| if need_check: # check for extra reqs | |
| yield from _yield_reqs_to_install(child_req_obj, ext) |
Only extras are iterated over to determine whether a child dependency should be processed.
What I think should happen
So IMO either a) the documentation of check_reqs should be updated to reflect the fact it only looks at packages that are dependencies of a top-level extra (or extras below that, recursively) or b) this should be fixed to behave the same as pkg_resources.require.
Thoughts?