Commit 961692b
fix(pip): scope direct dependencies, name project roots, diagnose old pip (#338)
* fix(pip): scope direct dependencies, name project roots, diagnose old pip
Three pip-detector fixes reported against 0.18.0.
Every installed distribution was reported as a direct dependency (#273).
`pip inspect` reports a flat installed set with no `requested_by` field, so
the `len(RequestedBy) == 0` clause was always true and hung every package
off the root. Edges now come from each distribution's `requires_dist`, and
the direct set from the names the project's requirements files declare plus
the installer's REQUESTED marker. Packages left without a parent are
re-parented onto the root so the graph keeps a single root.
requirements.txt projects rendered as the literal `root` in the manifest
tree (#272). Roots are now named after `pyproject.toml`'s project name, the
subproject directory, the scanned repository, or the project directory —
in that order. Bomly's own `bomly-git-*` clone directories are skipped so
remote scans stay deterministic.
`pip inspect` failed opaquely on machines whose ambient pip predates 22.2
(#274), which is where the command was added; the venv inherits that pip
from `python -m venv`. Bomly now upgrades pip inside its own isolated temp
venv, and when that cannot run, fails with the pip version and the minimum
named instead of `exit status 1`. Documented the requirement in the pip and
pipenv prerequisites, and corrected the network-behavior row that claimed
`pip inspect` never reaches the network.
Regenerated the three affected smoke goldens (root rename only).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(pip): scope declarations to manifests and diagnose old pip without upgrading
Review follow-ups.
[P1] The direct-dependency set came from declaredPythonDependencies, which
also reads poetry.lock, uv.lock, and Pipfile.lock. Since the pip-inspect
path is shared by Poetry, uv, and Pipenv, their fallback would have marked
every locked transitive as direct — #273 all over again for those
detectors. Direct declarations now come from a dedicated collector that
reads only hand-authored files: requirements.txt / -dev / .in, the
dependency tables of pyproject.toml (PEP 621, PEP 735, Poetry, uv), and the
Pipfile. requirements.lock is excluded for the same reason as the other
lockfiles. declaredPythonDependencies keeps its looser semantics for the
tool-package filter, which asks a different question.
[P1] Dropped the pip self-upgrade. Installing or upgrading a package
manager violates the repository's non-negotiable contract, and routing it
through base.install also appended the project's --install-arg values to
the bootstrap. The detector now only diagnoses: it reads the venv's pip
version before installing anything and fails with the version and the
minimum named. The fallback still produces a graph, so the user sees an
actionable notice instead of "exit status 1".
Also from review: reattach orphans by root-reachability rather than parent
count, so a requires_dist cycle cannot strand a component; wrap the
declaration-collection error with context; log the pip --version subprocess
at DEBUG with binary, args, and working dir; and correct the documented
root-naming chain, which omitted the subproject and repository fallbacks.
Goldens re-verified against the pinned smoke repos: unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 10dc47e commit 961692b
23 files changed
Lines changed: 914 additions & 149 deletions
File tree
- dev-docs
- docs
- detectors/ecosystems/python
- internal
- detectors/python
- support
- prose/detectors
- test/smoke/testdata/golden
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
380 | 388 | | |
381 | 389 | | |
382 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
0 commit comments