Skip to content

🐛 fix(zipapp): bundle wheels pinned by a PEP 751 lock - #3306

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/zipapp-hashed-deps
Sep 23, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/zipapp-hashed-deps

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

The zipapp build ran pip download against the version ranges from pyproject.toml, so each published virtualenv.pyz bundled whatever PyPI served for distlib, filelock, platformdirs, python-discovery and typing-extensions at build time. 📦 The threat model in #3294 lists this as an open item.

pylock.zipapp.toml now locks those dependencies in the PEP 751 format, with a URL and sha256 for every wheel. uv pip compile pyproject.toml --universal --python-version 3.9 -o pylock.zipapp.toml writes it from the [project] dependencies, so no second copy of the ranges exists to drift. The file sits at the repository root because PEP 751 places a lock that covers one pyproject.toml in the same directory. make_zipapp.py reads the lock with tomllib, downloads each wheel from its recorded URL, refuses any file whose sha256 differs, and assigns wheels to Python versions by evaluating the lock markers. I dropped the pip-based dependency walk; the lock holds the resolution for every Python version the zipapp targets. 🔒

Dependabot has no pylock.toml support yet (dependabot/dependabot-core#12094 is open, and the supported ecosystems reference lists no such manifest). The daily upgrade workflow recompiles the lock with --upgrade and UV_EXCLUDE_NEWER="7 days", the same cooldown check_wheel_age.py applies to embedded wheels, and apply_upgrade_patch.py accepts pylock.zipapp.toml as one more allowed path. ⏳ Before this change a release build bundled whatever PyPI served at build time. A new dependency release now reaches the zipapp once the upgrade workflow recompiles the lock after the seven day cooldown. The committed lock follows that rule, so the zipapp bundles filelock 3.32.6 until filelock 4.0.1, uploaded on 2026-09-19, clears the cooldown on 2026-09-26; platformdirs 4.11.8 and python-discovery 1.6.0 lag their newest releases the same way. The zipapp SBOM from #3310 reads the built archive, so it lists these locked versions. Running make_zipapp.py on Python 3.9 or 3.10 needs tomli; the zipapp tox environment builds on 3.14.

@gaborbernat gaborbernat added bug security Fixes a vulnerability or hardens the supply chain, CI or release labels Sep 22, 2026
@gaborbernat
gaborbernat force-pushed the fix/zipapp-hashed-deps branch from 50d7194 to 2d13f58 Compare September 22, 2026 23:51
@gaborbernat gaborbernat changed the title 🐛 fix(zipapp): pin bundled dependencies by hash 🐛 fix(zipapp): bundle wheels pinned by a PEP 751 lock Sep 23, 2026
@gaborbernat
gaborbernat force-pushed the fix/zipapp-hashed-deps branch from 2d13f58 to 7abe24c Compare September 23, 2026 00:21
@gaborbernat
gaborbernat force-pushed the fix/zipapp-hashed-deps branch 2 times, most recently from aad41f1 to b34a127 Compare September 23, 2026 01:15
The zipapp build ran pip download against the version ranges in
pyproject.toml, so each published zipapp bundled whatever PyPI served at
build time, with nothing to check those bytes against.

Lock the runtime dependencies in pylock.zipapp.toml, the PEP 751 format
uv writes from pyproject.toml, next to the pyproject.toml it locks as
the PEP recommends. The build reads the lock, downloads each wheel from
its recorded URL and refuses any file whose sha256 differs. Compiling
from pyproject.toml drops the requirements copy that had to track the
declared ranges by hand.

Dependabot cannot update pylock.toml files yet
(dependabot/dependabot-core#12094), so the daily upgrade workflow
recompiles the lock with the same seven day cooldown it applies to
embedded wheels, and the patch validator accepts that one file.
@gaborbernat
gaborbernat force-pushed the fix/zipapp-hashed-deps branch from b34a127 to 7397b50 Compare September 23, 2026 01:19
@gaborbernat
gaborbernat merged commit b80a3bd into pypa:main Sep 23, 2026
65 checks passed
gaborbernat added a commit to gaborbernat/virtualenv that referenced this pull request Sep 26, 2026
The verify-release how-to said the zipapp build does not pin what it
bundles, which stopped being true when pypa#3306 added pylock.zipapp.toml, and
the threat model still said wheels differ between build machines after
pypa#3311. Neither page covered the release attestation GitHub signs for the
immutable releases published since 21.11.0.

Move the examples to 21.12.1, add gh release verify and verify-asset, and
give a zipapp rebuild recipe that constrains the build tools from the SBOMs.
Fix the same claims in the release artifacts reference, the explanation and
the threat model, whose upgrade job note also named a deploy key that the
workflow does not use.
@gaborbernat
gaborbernat deleted the fix/zipapp-hashed-deps branch October 3, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant