← Back to issue list

Fix uv plugin not caching wheels to LXC host

View original Github issue

Metadata

Project
charmcraft
Number
#2501
Type
pull request
State
open
Author
Copilot
Labels
Created
2025-12-03 18:32:58+00:00
Updated
2025-12-08 21:21:31+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

## Description Fixes an issue where the UV plugin doesn't cache wheels built from source when `no-binary = true` is set in pyproject.toml. Wheels built during charm packing were not being saved to charmcraft's cache on the LXC host, causing them to be rebuilt on every pack operation. ## Changes Made - **UV Plugin**: Added `UV_CACHE_DIR` environment variable in the UV plugin's build environment to point to the part's cache directory (`charmcraft/parts/plugins/_uv.py`) - **Unit Tests**: Added `test_uv_cache_dir_set` to verify UV_CACHE_DIR is properly configured - **Unit Tests**: Updated `test_get_build_environment` to check for UV_CACHE_DIR presence - **Spread Test**: Created comprehensive end-to-end test at `tests/spread/smoketests/uv-cache/` with two separate UV-based charms to verify caching works correctly - **Linting**: Fixed trailing whitespace and formatting issues in test files - **Test Structure**: Fixed spread test charm structure by moving charm files to required `src/` directory and making them executable ## Testing - ✅ Tested on tag 4.0.1 to confirm issue exists - ✅ Tested on hotfix/3.5 branch (issue exists) - ✅ Tested on hotfix/2.7 branch (N/A - UV plugin doesn't exist) - ✅ Tested on main branch (issue exists) - ✅ All existing UV plugin unit tests pass - ✅ New unit test validates UV_CACHE_DIR configuration - ✅ New spread test validates cache reuse between builds - ✅ Security checks passed (CodeQL found no issues) - ✅ Code review completed - ✅ All linting checks pass - ✅ Spread test structure corrected with proper charm directory layout --- - [ ] I've followed the [contribution guidelines](https://github.com/canonical/charmcraft/blob/main/CONTRIBUTING.md). - [ ] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [ ] I've successfully run `make lint && make test`. - [ ] I've added or updated any relevant documentation. - [ ] I've updated the relevant release notes. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>uv plugin doesn't cache wheels to LXC host</issue_title> > <issue_description>### Bug Description > > When the uv plugin is used with > ```toml > # pyproject.toml > [tool.uv] > no-binary = true > ``` > wheels built from source are not saved to charmcraft's cache on the LXC host > > ### To Reproduce > > ```shell > git clone https://github.com/carlcsaposs-canonical/bug-report-charmcraft-uv-no-cache > cd bug-report-charmcraft-uv-no-cache/ > mkdir ~/foo > CRAFT_SHARED_CACHE=/home/ubuntu/foo charmcraft pack -v > ``` > ```shell > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/ > charmcraft-buildd-base-v7 charmcraft.lock > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/ > BuilddBaseAlias.NOBLE > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/BuilddBaseAlias.NOBLE/ > pip > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/BuilddBaseAlias.NOBLE/pip/ > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ > ``` > > ### Environment > > Ubuntu 24.04 > Using charmcraft with lxc containers > > ### charmcraft.yaml > > ```yaml > type: charm > platforms: > ubuntu@24.04:amd64: > parts: > charm-uv: > plugin: uv > source: . > build-snaps: > - astral-uv > ``` > > ### Relevant log output > > ```shell > N/A > ```</issue_description> > > <agent_instructions>1. Write a test for this that fails when run from the 4.0.1 tag. > 2. Check whether it succeeds on the `hotfix/3.5` branch. > 3. Check whether it succeeds on the `hotfix/2.7` branch. > 4. Check whether it succeeds on the main branch. > > If the test fails on `hotfix/3.5`, target your fix PR at that branch. If it succeeds on both `hotfix/3.5` and `main` but fails on `hotfix/2.7`, write a fix for that branch. > > If it fails on the 4.0.1 tag but succeeds everywhere else, write a comment that this will be resolved in version 4.1.0 and close the issue.</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes canonical/charmcraft#2461 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Evaluation history

No evaluation history available.