Repository navigation
pixi.lock input: check the PyPI packages of a pixi environment - #251
Merged
Merged
Conversation
A strict reader for the block-YAML subset pixi writes (lock versions 6 and 7, no YAML library); any other version or construct is a SourceError naming the file. --environment picks the environment (default: `default`). Conda packages are skipped as `conda`. pixi records only the file it picked per platform, so PyPI packages are always looked up on the index (partial_files), --offline refuses them, and a package left out on one of the lock's platforms is hidden only for that platform's markers and Python. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ricter reader - Hide a package only when it's missing from every locked platform with the same sys_platform, platform_machine and Python (linux-64 and linux-64-cuda are one group), so no wrong n/a on rich platforms or per-variant versions. - A partial_files package is looked up or skipped, never judged on its locked file: not kept under --online, and its files are dropped if the lookup fails. - The YAML reader refuses tabs and control characters anywhere, other line breaks, a BOM after the start (a leading one is stripped), a space before a colon, `k: -`, document markers with content, and escapes that aren't Unicode characters. - --environment "" is an error; with --environment a project directory reads pixi.lock, otherwise a note names the pixi.lock passed over. - Conda packages are skipped once per name and counted past five in text and Markdown output; check_lockfile() takes environment=. - Tests for each, and for the reviews' mutation survivors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A package installed on a platform whose Python isn't known (built from source, say) is never hidden on that platform's sys_platform and machine, since that Python may be the one a group of the same markers has. - The reader refuses U+FFFE and U+FFFF, as libyaml does. - A pixi.lock that isn't valid UTF-8 is a `pixi.lock: ...` SourceError. - Tests for these and for the remaining mutants: platforms sharing a subdir with different Pythons, U+2029, \U0010FFFF accepted, exactly six conda packages, and conda counted next to a named git package. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md
patrickballard
added a commit
that referenced
this pull request
Nov 12, 2026
…rdening pixi.lock's PyPI package names now go through package_name like the other lockfiles' (conda names are left alone: they aren't PEP 508 names). Its quoted-scalars test used the name pure'wheel, which is now an input error; it uses purewheel, and test_block_yaml_reads still covers ''. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 12, 2026
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.
Closes #229
Made with Claude Code.
wheelgap now reads
pixi.lockand checks the PyPI packages of one pixi environment.Supported lock versions: 6 and 7
rattler_lock's
FileFormatVersion(crates/rattler_lock/src/file_format_version.rsin conda/rattler) defines versions 1 to 7, with 7 as the latest. pixi has written version 7 since 0.68.0 (2026-05-07). I looked at eight publicpixi.lockfiles: matplotlib/ipympl, stanford-oval/WikiChat, pinellolab/CRISPResso2 and pyjanitor-devs/pandas_flavor are on v6; prefix-dev/pixi, conda/grayskull, ericmjl/nxviz and Quansight-Labs/uarray are on v7. wheelgap reads 6 and 7. Any otherversionis aSourceErrornaming the file. Versions 4 and 5 used a different package layout (kind: pypi), and anypixi lockwith a current pixi rewrites them.How pixi records PyPI packages, and what that means here
environments.<name>.packages.<platform>lists selectors (- pypi: <location>,- conda: <url>, and in v7- conda_source: name[hash] @ path). Each selector points at a top-levelpackages:entry with the same location.pypi:(a URL or path),name,version(in v7, missing for source/path packages),sha256/md5,requires_distandrequires_python. v6 can also haveeditable: true; v7 can haveindex:(written only when the index isn't PyPI) andbuild_packages/host_packages.So the recorded filenames become the package's files, as the issue asks, but on their own they would give false gaps on any target the lock doesn't match exactly. Examples: a different Python,
musl, or wheelgap's default glibc 2.36 against pixi's 2.28. So these packages are markedpartial_files:fill_allalways looks them up on PyPI for the pinned version, which the 24-hour cache covers. A failed lookup isunknown, not the recorded sdist.--offlinerefuses the file, naming why.private index, as for a Pipfile.lock. The exception is whenWHEELGAP_INDEX_URLpoints at that same index (may_look_up).Which index a package came from:
index:is used when present.files.pythonhosted.orgis PyPI's.url), since PyPI serves files only from that host.private index, because a v6 lock doesn't record which index a package came from.Other packages:
git,path,editable).conda, so they show under "skipped".Platform-specific packages. pixi resolves each platform separately. Locked platforms are grouped by the markers pip sees there:
sys_platform,platform_machineand the environment's Python version, read from the condapython-X.Y.Z-…package. Solinux-64and alinux-64-cudawith subdirlinux-64are one group. A package missing from every platform of a group, saypywin32locked onwin-64only, gets a marker that is false exactly on that group's markers. That way it showsn/athere instead of a false gap. Targets on platforms the lock doesn't cover, and other Pythons, still count it. That follows wheelgap's existing rule that only a definite False hides a package. 32-bit x86/Arm subdirs get no marker (theirplatform_machineisn't certain).The reader
There's no YAML library.
_BlockYamlinsources.pyreads the block subset serde_yaml writes:[]and{}.Everything else is refused with
pixi.lock: can't read it for sure: line N: …: anchors, aliases, tags, block scalars, flow collections with content, multi-line scalars, comments, tabs, document markers, duplicate keys and non-string keys.On top of that it also refuses:
channels,indexes,find-links,options,packages);packages;platforms;indexes;Conda entries must be valid in the subset, but their contents aren't interpreted beyond the name and version.
All 38 environments in the eight real lockfiles above parse.
Environment selection:
--environment NAME, not--group--environment(defaultdefault) matches pixi's own-e/--environmentand its term. In wheelgap,--groupadds a dependency group to what's installed (uv, Poetry, PDM), and--no-devand--only-groupbuild on that. A pixi environment is a whole, separately solved package set: you pick exactly one, and it can't be combined with others. Reusing--groupwould give it a second, conflicting meaning. An unknown environment is an error listing the lock's environments, and--environmentwith no pixi.lock input is an error.--groupon a pixi.lock keeps the existing "requires uv.lock inputs" error.Targets from the lock's platforms: not done (note for later)
The subdirs map cleanly to platforms (
linux-64tolinux-x86_64,osx-arm64tomacos-arm64,win-64towin-amd64). The rest of a target doesn't:virtual_packages);Defaulting from the lock would mean guessing or silently differing from pixi, so the targets stay wheelgap's defaults. A later step could read
[system-requirements]frompixi.tomlor the lock's virtual packages.Other changes
pixi.lockis detected in a project directory, last inLOCKFILES, so a directory that already has another lockfile is read as before..pre-commit-hooks.yamlfilespattern, the README input list, a usage example, a "How it works" bullet, AGENTS.md'ssources.pyrow, and the CHANGELOG.tests/fixtures/pixiproj/pixi.lock(v7; linux-64, osx-arm64, win-64; environmentsdefaultandtest).Verification
ruff format,ruff check,mypy,pytestall pass (1637 passed).test_pixi_lock,test_pixi_lock_environment,test_pixi_lock_version_6(both index cases);test_pixi_lock_refuses_what_it_cannot_read_for_sure: 27 malformed variants, from versions 5 and 8 to anchors, block scalars, flow lists, comments, tabs, unknown keys, dangling selectors and unknown schemes. Each must be aSourceErrorstartingpixi.lock:with the expected reason;unknown,--environmenterrors, and the--offlinerefusal.fill_all'spartial_fileslookup: 3 tests;require_offlinechange: 1;-p 3.13 -t all) and ipympl (--environment docs) gave sensible results. The lookups went to the pinned versions, and the conda packages were listed as skipped.For the maintainer
--offlinerefuses a pixi.lock with PyPI packages, because pixi's single pick per platform can't answer other targets. If you'd rather keep--offlineworking with a "may show false gaps" note, as for the uv.lock requires-python case, that's a small change. I chose an error because here nearly every off-lock target would be affected.environmentkey in[tool.wheelgap];environmentargument for the MCP tools (they usedefault;check_lockfile()now takesenvironment=);--github-annotationsline numbers for pixi.lock (it names the file without a line);llms.txtand the agent integrations (released behaviour only).Review fixes (d8da984)
n/awhen platforms share a subdir, or when two versions are locked on two variants of one subdir.partial_filespackage is never judged on its locked file. It isn't kept under--online(a v7index:package withWHEELGAP_INDEX_URLpointing at that index is looked up), and a failed lookup drops its files (unknown, no files incheck_lockfile()results).\x7f;\n/\r;k: -, and---/...lines with content;\Uabove 0x10FFFF).--environment ""is an error. With--environment, a project directory readspixi.lockeven next to auv.lock; without it, a stderr note names thepixi.lockthat was passed over.105 conda packages (not on PyPI));--jsonlists each one.check_lockfile(..., environment=).files.pythonhosted.orgare checked as PyPI packages; MCP and[tool.wheelgap]readdefaultonly.allvsanyover indexes, version consistency, duplicate locations, merge keys, machine and subdir mapping, the Python package match, a platform without Python, and the LOCKFILES order. 1710 passed. I reverted the grouping, the never-kept and dropped-files changes, and the conda-by-name key one at a time and confirmed tests fail without each.🤖 Generated with Claude Code