Pin pyproject.toml PyPI dependencies to exact pixi.lock versions - #417
Open
mkitti wants to merge 3 commits into
Open
Pin pyproject.toml PyPI dependencies to exact pixi.lock versions#417mkitti wants to merge 3 commits into
mkitti wants to merge 3 commits into
Conversation
Adds scripts/sync_pyproject_versions.py to sync [project.dependencies], [project.optional-dependencies], and [dependency-groups] to the exact versions pixi resolved, so `pip install fileglancer` matches the pixi/conda environment. Where a package resolves differently across pixi environments or platforms, the entry is split into multiple python_version/sys_platform/ platform_machine-qualified requirements instead of a single pin. Adds .github/workflows/sync-pypi-versions.yml to run the script and open a PR whenever pixi.lock changes on main (or on manual workflow_dispatch). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 29, 2026
Exact-pinning [project.dependencies] etc. feeds directly back into pixi's
own solve (via the editable fileglancer package's own metadata), so once
pinned, `pixi update` had no room to move a package forward and could even
fail outright if a conda-resolved version diverged from the pin.
scripts/sync_pyproject_versions.py --unpin restores each dependency to a
semver range instead of an exact pin -- from the matching [tool.pixi.*]
table where one exists, or from the new [tool.sync-pypi-versions.ranges]
table for the three PyPI-only packages (x2s3, py-cluster-api, build) that
have no such mirror. The intended maintenance cycle is now:
pixi run unpin-pypi-versions && pixi update && pixi run sync-pypi-versions
or the equivalent single `pixi run bump-pypi-versions` task.
Also includes the pixi.lock update from `pixi update` (transitive/build
tooling only -- libgcc, uv, prompt-toolkit, etc. -- since re-running the
full unpin/update/re-pin cycle landed back on identical exact versions for
every package sync_pyproject_versions.py manages).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hatch_build.py registers a Hatchling build hook that runs `scripts/sync_pyproject_versions.py --check` before a *standard* wheel build and fails loudly if pyproject.toml's PyPI dependency versions don't match pixi.lock -- catching a forgotten `pixi run sync-pypi-versions` after `pixi update` before it gets published. The hook explicitly skips editable builds (version == "editable"), since pixi resolves editable-install metadata constantly -- including while pyproject.toml is intentionally unpinned mid `pixi run bump-pypi-versions` -- and that must not fail. Verified against a real `pixi run -e release pypi-build`: succeeds and prints the check result when pinned, fails with a clear error when not, and the built wheel's METADATA carries the exact pins. Adds pyyaml to [build-system].requires so the check script can actually import it inside the isolated build environment pip/build creates (which only contains the declared build-system requirements, not pixi's runtime deps). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
scripts/sync_pyproject_versions.py, which readspixi.lockand rewrites[project.dependencies],[project.optional-dependencies], and[dependency-groups]inpyproject.tomlto the exact versions pixi resolved, sopip install fileglancermatches the pixi/conda environment as closely as possible.python_version/sys_platform/platform_machinemarkers instead of a single pin, so bothpip installandpixi installstay satisfiable.sync-pypi-versionspixi task (pixi run sync-pypi-versions) so the script is easy to run locally..github/workflows/sync-pypi-versions.yml, which runs on push tomain(or manualworkflow_dispatch), checks whetherpixi.lockchanged, runs the script, and opens a PR with the resultingpyproject.tomldiff.--unpinmode: because the exact pins become part of the editablefileglancerpackage's own metadata, pixi feeds them back into its own solve on everypixi update-- an exact pin can't move, and can even makepixi updatefail outright if a conda-resolved version has since diverged from it.pixi run unpin-pypi-versionsrestores each dependency to a semver range (from the matching[tool.pixi.*]table, or the new[tool.sync-pypi-versions.ranges]table for the three PyPI-only packages --x2s3,py-cluster-api,build-- that have no such mirror), sopixi updatehas room to move again. The intended cycle ispixi run unpin-pypi-versions && pixi update && pixi run sync-pypi-versions, or the singlepixi run bump-pypi-versionstask.hatch_build.py): registers a Hatchling build hook that runssync_pyproject_versions.py --checkbefore a standard wheel build and fails loudly ifpyproject.tomldoesn't matchpixi.lock-- catching a forgotten re-pin before it gets published. It explicitly skips editable builds, since pixi resolves editable-install metadata constantly (including while intentionally unpinned mid-bump-pypi-versions), and that must not fail. Also addspyyamlto[build-system].requiresso the check script can import it inside the isolated build environment pip/build creates.pixi.lockto reflect the new exact pins (only thefileglancerpackage's ownrequires_distmetadata changes, plus an earlierpixi updatethat bumped unrelated transitive/build tooling).Test plan
pixi run sync-pypi-versions/pixi run unpin-pypi-versionsare each idempotent when run twice in a rowunpin->pixi update->sync) round-trips back to identical exact versionspixi install -e default|test|release|test-py312all succeed after the pins are appliedcoveragepackage (which builds differently on macOS x86_64 + Python 3.12 vs. everywhere else) correctly splits into two marker-qualified entries, and thatpixi.lockre-locks it as the equivalentpython_full_version/platform_machine/sys_platformmarkerpixi run -e release pypi-buildsucceeds when pinned (and the built wheel's METADATA carries the exact pins/markers) and fails with a clear error when deliberately left unpinnedbuild.yml) passes on this branchsync-pypi-versions.ymlviaworkflow_dispatchto confirm the PR-opening step works end-to-end🤖 Generated with Claude Code