pack: include the charm libraries dependencies (CRAFT-1559)
Metadata
Current evaluation
Merged changes integrating charm library dependencies into the pack process. Introduces a charmlibs helper to collect PYDEPS, updates library parsing, and refactors get_libs_from_tree. Approved and merged after CI checks.
Suggested action: —
No scores available.
Issue body
There are two situations where these dependencies need to be used:
- in the Builder when it decides if the `venv` directory needs to be primed
- in charm_builder when dependencies are actually handled (hashed, installed, etc.)
I created a helper to collect all the dependencies, used from those two places. Located it in the charmlibs module for convenience (initially I thought putting it in `charmcraft/utils` but hit a circular import).
Alternatively, these dependencies could have been collected where other dependencies are defined or dynamically included: in the CharmPluginProperties class. This will make "pydeps" management much more similar to standard python packages or requirements files, but there are several drawbacks of this path:
- a new `charm_libs_deps` or similar key would have need to be included, even if that key should not be exposed to the user as a real config key
- an extra validator would need to be added to collect all PYDEPS values, which would be called *twice* (when config is validated, and when the plugin is actually run), so there is no drawback in calling the collection twice in the current model
- furthermore, that validator would have been executed (and all PYDEPS collected) when the config is validated *for any command* (e.g. `charmcraft names`)
Also, I include here these needed changes in the charm libraries:
- included PYDEPS in the parsing of a library internals
- added a `root` parameter to the `get_libs_from_tree` function; notably, this function relied on being on the project's root directory, which is suspicious, so I opened #1002 to ensure everything is fine (or fix it)
- moved the `emit` usage out of `get_libs_from_tree` as it is now used also from the charm_builder.py, called from the plugin, as a standard subprocess that does not use the Craft CLI infrastructure.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged changes integrating charm library dependencies into the pack process. Introduces a charmlibs helper to collect PYDEPS, updates library parsing, and refactors get_libs_from_tree. Approved and merged after CI checks. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Introduced a helper to collect charm library dependencies (PYDEPS) for the Builder and charm_builder. Refactored get_libs_from_tree to accept a root parameter and decoupled it from CLI emit. Resolves CRAFT-1559. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Added a charmlibs helper to collect charm library dependencies for the Builder and charm_builder. Updated library parsing to include PYDEPS and refactored get_libs_from_tree for correct dependency handling during packaging. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1918 feat(pack): automatically install non-matching charmlibs | charmcraft | merged | Merged. The pack command now automatically upgrades charmlibs on disk that do not match charmcraft.yaml specifications. Approved by two reviewers and implemented by maintainer lengau. | |
| #2250 feat(linters): PYDEPS linter | charmcraft | merged | Merged after two approvals. Added a PYDEPS linter to verify charmlib package consistency, resolving #1890 and CRAFT-3370. The author overrode a single failing spread test caused by infrastructure issues to complete the merge. | |
| #105 feat: charmcraft/pack with typescript | craft-actions | merged | Merged after approval and passing CI checks. Rewrites the charmcraft/pack command in TypeScript to align with other pack commands, addressing CRAFT-5205. The change modifies 14 files. | |
| #295 Update charm library template for correct command to publish or update libraries | charmcraft | merged | Merged a fix to update the charm library template with the correct command, replacing the non-existent charmcraft push-lib. Approved by two reviewers with minimal changes. |