feat(plugins): add pylock craft-parts plugin - #3
Open
tonyandrewmeyer wants to merge 1 commit into
Open
Conversation
Add a `pylock` craft-parts plugin to charmcraft that installs a charm's venv from a PEP 751 pylock.toml lock file. The plugin is tool-agnostic: a pylock.toml produced by uv, PDM, pip-tools or `pip lock` is installed with pip itself, so the producing tool doesn't need to be present in the build environment. Because pip's `-r pylock.toml` support is experimental and only landed in pip 26.1, the plugin upgrades pip inside the venv before installing the lock file. Unlike the existing python/poetry/uv plugins, the venv is created with pip available and without `PIP_NO_BINARY`, so the wheel hashes pinned in pylock.toml match at install time; the resulting venv's `bin/` is still stripped by the normal cleanup. Ships with 15 unit tests, a pylock_plugin fixture, an integration test mirroring test_uv.py, a spread fixture under `tests/spread/ubuntu-26.04/charm/pylock/`, and reference + migration docs.
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.
This PR is against my own fork, not upstream — opened for self-review before raising upstream.
Summary
Adds a
pylockcraft-parts plugin to charmcraft that installs a charm's venv from a PEP 751pylock.tomllock file. The plugin is tool-agnostic: apylock.tomlproduced by uv, PDM, pip-tools or `pip lock` is installed with pip itself, so the producing tool doesn't need to be present in the build environment.Because pip's `-r pylock.toml` support is experimental and only landed in pip 26.1, the plugin upgrades pip inside the venv before installing the lock file. Unlike the existing `python`/`poetry`/`uv` plugins, the venv is created with pip available and without `PIP_NO_BINARY`, so the wheel hashes pinned in `pylock.toml` match at install time; the resulting venv's `bin/` is still stripped by the normal cleanup.
Ships with 15 unit tests, a `pylock_plugin` fixture, an integration test mirroring `test_uv.py`, a spread fixture under `tests/spread/ubuntu-26.04/charm/pylock/`, and reference + migration docs.
Provenance
The patch tree of record is `non-roadmap/pylock-charmcraft/` in `tonyandrewmeyer/canonical-work-queue`:
This branch is the patch applied on top of upstream `4ef9d389` (fork `main` was fast-forwarded to match), then committed.
Local verification (re-run today before pushing)
Integration tests (`tests/integration/parts/plugins/test_pylock.py`) and the spread fixture were exercised in the original prototype run — see PLAN.md §"Verification done locally" and REBASE-REPORT.md.
Notable design choices (worth a second look during self-review)
Test plan