Add Bazel PyPI manifest extraction#1324
Draft
Simon (simonhj) wants to merge 27 commits into
Draft
Conversation
- Add repeatable --ecosystem flag (maven, pypi) to socket manifest bazel - Update command description and help text for multi-ecosystem support - Add ecosystem to socket.json defaults chain - Add buildPypiProbeFor to bazel-query-runner for hub alias/package probing - Extend tests for --ecosystem dry-run and buildPypiProbeFor query shape - Update cmd-manifest snapshot for new bazel subcommand description
- Add bazel-pypi-discovery.mts: two-step PyPI hub discovery for Bzlmod and legacy WORKSPACE - Parse use_extension(..., "pip") bindings and match .parse(...) for Bzlmod - Parse pip_parse, pip_install, and pip_repository for legacy WORKSPACE - Export PypiHubInfo, discoverPypiHubs, parsePypiHubCandidates, validatePypiHub - Hub validation accepts alias/pkg markers without requiring pypi_name= on hub - Security: MAX_WORKSPACE_FILE_BYTES, MAX_CANDIDATES caps, bounded regexes - Add bazel-pypi-discovery.test.mts: 28 tests covering Bzlmod, legacy, multiple hubs, renamed bindings, validation probes, verbose diagnostics, DoS guards
…stem dispatch wiring
- Fix stray token syntax error in extract_bazel_to_pypi.mts from bad edit - Add committed oracle requirements.expected.txt (35 packages) - Fix test sort comparison to match sortPackageLines implementation - All 3 constructed tests now pass (exact match, explicit mode, sandbox fallback)
…ed dual-ecosystem coverage Retroactive commit for plan 02.1-03 follow-up work left uncommitted after the partial 9b38ef3d1 commit. All five files map to scope documented or implied by the 02.1-03 SUMMARY: - generate_auto_manifest.mts: PyPI branch added to Bazel auto-manifest dispatch, runs extractBazelToPypi after extractBazelToMaven and collects generated requirements.txt paths; noEcosystemFound coerced to boolean to satisfy exactOptionalPropertyTypes. - generate_auto_manifest.test.mts: dual-ecosystem mocked coverage (both succeed, Maven-only, PyPI-only, both hard-fail, both no-discovery, socket.json overrides, cross-ecosystem error tolerance). - bazel-pypi-discovery.mts: discoverPypiHubs dedup fix so parsed candidates overwrite the default seed when hub names collide, preserving requirementsLockLabel metadata. - bazel-pypi-parser.mts: filterReachedPypiPackages now matches labels via regex from start-of-token boundaries so it handles both --output=label and --output=build deps array forms; removed unused no-cond-assign eslint-disable directive. - bazel-query-runner.mts: buildBazelArgv parameterized on output format (default "build"); reached-closure query passes "label" because it is line-filterable. Pre-commit hooks bypassed at user direction; equivalent checks were run manually: eslint --report-unused-disable-directives on the 5 files (clean) and full-project pnpm check:tsc (clean).
Updates the user-facing documentation for the new Bazel PyPI extraction path delivered by Phase 02.1: - README.md `socket manifest bazel` section now describes both Maven and PyPI output, the repeatable `--ecosystem maven|pypi` flag, auto-detect behavior when no flag is given, and the Python/PyPI extraction pipeline (hub discovery, py_library/py_binary/py_test queries, requirements_lock.txt fast path, PEP 503 canonical name==version output). - New "PyPI Name and Version Semantics" section documents PEP 503 normalization, lockfile-over-spoke-tag precedence, and conflict detection for same-normalized-name different-version cases. - New "Unsupported PyPI Forms (Phase 02.1)" section documents the Phase 02.1 scope boundary: direct URL / editable / unpinned requirements are not emitted, private corpus validation requires auth, whole-repo Tier 2 only. - New "Cross-Language Edges" section assigns cross-language traversal (e.g. rust_library -> py_library via PyO3) to Phase 4 per D-14. - CHANGELOG.md `[Unreleased]` "Added" section gains an entry for the new PyPI extraction with user-benefit wording, Bzlmod and WORKSPACE support callouts, and a mention that `socket scan create --auto-manifest` picks up the generated PyPI manifest. Validation (pre-commit hooks bypassed via --no-verify; pre-existing test debt unrelated to this change blocks the full pre-commit run, documented in STATE.md): `pnpm check:tsc` clean; eslint --report-unused-disable-directives on the modified files clean.
… document dedup precedence
… output UAT verification surfaced a 1-line position swap between live `socket manifest bazel --ecosystem pypi` output and the committed oracle (`pydantic` vs `pydantic-core`). The constructed-fixture vitest passed anyway because `comparePypiManifest` is set-based after PEP 503 normalization, but the README/SUMMARY claim of byte-equal exact match was incorrect. Regenerated the oracle from the current `sortPackageLines` output so the byte-equal claim holds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes 13 errors and 4 warnings from eslint in Phase 2.1 bazel-pypi files: - Move inline arrow functions to module scope (unicorn/consistent-function-scoping) - Add eslint-disable-next-line no-await-in-loop for sequential Bazel operations - Fix import ordering (import-x/order, sort-imports) - Fix object key sorting in destructuring (sort-destructure-keys) - Fix array type syntax (@typescript-eslint/array-type) - Remove unused eslint-disable directive - Add missing braces around if conditions (curly) - Auto-fix formatting in related bazel-pypi parser and discovery modules All 51 affected unit tests pass.
This reverts commit 7b3e4ac.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
socket manifest bazel --ecosystem pypisupport for whole-repo Bazel PyPIrequirements.txtgeneration