Skip to content

refactor(pypi): parse the versions with pypackaging.bzl - #4564

Open
aignas wants to merge 8 commits into
refactor.aignas.pypackaging-07-python-versionsfrom
refactor.aignas.pypackaging-08-pypi-versions
Open

aignas wants to merge 8 commits into
refactor.aignas.pypackaging-07-python-versionsfrom
refactor.aignas.pypackaging-08-pypi-versions

Conversation

@aignas

@aignas aignas commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Use pypackaging.version instead of version.bzl in the PyPI
integration.

Summary by CodeRabbit

  • Bug Fixes
    • Invalid version numbers and version specifiers, PEP 508 requirements, and environment markers now fail validation instead of being silently accepted. This makes malformed packaging metadata easier to identify and prevents it from being treated as valid.

Use `pypackaging.version` instead of `version.bzl` in the PyPI
integration.
@aignas

aignas commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

This PR was prepared by an AI agent (Claude Code) on behalf of @aignas. The agent replies to the review comments and pushes the fixes, @aignas supervises it and reviews the changes.

This is an agent-generated comment unreviewed by the user.

@aignas
aignas added this pull request to stack #4570 November 22, 2026 04:18
@aignas
aignas marked this pull request as ready for review November 22, 2026 08:41
@aignas
aignas requested a review from rickeylev as a code owner November 22, 2026 08:41
…factor.aignas.pypackaging-08-pypi-versions

# Conflicts:
#	news/pypackaging-bzl.changed.md
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Python version parsing

Layer / File(s) Summary
Switch PyPI version parsing to pypackaging
python/private/pypi/BUILD.bazel, python/private/pypi/hub_builder.bzl, python/private/pypi/pep508_env.bzl, python/private/pypi/pip_repository.bzl, news/pypackaging-bzl.changed.md
The three PyPI libraries replace their local version dependency with pypackaging and update their Python version parsing calls. The changelog adds invalid versions and version specifiers to its documented failure cases.

Possibly related PRs

Suggested reviewers: dougthor42

Change: Refactor

Merge Risk: Minimal · up to 7e79f

This change moves PyPI version parsing to pypackaging.bzl and documents that invalid versions now fail. No concrete merge-blocking risk was identified.

Architecture risk: Low · up to 7e79f

The change affects 2 systems.

Changed systems: python, news

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — python (service) was modified; 4 changed files map to changed impact.
  • observed — news (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in news/pypackaging-bzl.changed.md: The changelog expands the documented invalid-input cases from PEP 508 requirements and environment markers to include versions and version specifiers.
  • observed — Modified behavior in python/private/pypi/BUILD.bazel: hub_builder removes its dependency on //python/private:version while retaining //python/private:version_label, and adds @pypackaging.bzl//:pypackaging.
  • observed — Modified behavior in python/private/pypi/BUILD.bazel: pep508_env replaces its //python/private:version dependency with @pypackaging.bzl//:pypackaging.
  • observed — Modified behavior in python/private/pypi/BUILD.bazel: pip_repository removes its //python/private:version dependency and adds @pypackaging.bzl//:pypackaging, retaining its other listed dependencies.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c93bc822-8611-495e-b047-7d42bf3a7203
Commits

Reviewing files that changed from the base of the PR and between d80168b and 7e79f92.

Files selected for processing: 5

  • news/pypackaging-bzl.changed.md
  • python/private/pypi/BUILD.bazel
  • python/private/pypi/hub_builder.bzl
  • python/private/pypi/pep508_env.bzl
  • python/private/pypi/pip_repository.bzl

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

evaluated like `packaging` does it, e.g. `platform_release` is compared as a
version and the ordered comparisons of strings are always false. `WORKSPACE`
users get `pypackaging.bzl` from {obj}`py_repositories`.
(pypi) Invalid versions, version specifiers, PEP 508 requirements and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much detail in the news. reduce to essential changed behavior relevant to users without the implementation details

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants