Skip to main content

charmcraftlocal

Pack charms with local Python package dependencies

Installation

Install pipx: https://pipx.pypa.io/stable/installation/

pipx install charmcraftlocal

Usage

At the moment, only charms that manage Python dependencies with Poetry are supported.

Example directory layout

common/
    # Local Python package with shared code
    pyproject.toml
    common/
        __init__.py
kubernetes/
    charmcraft.yaml
    pyproject.toml
    poetry.lock
    # [...]
machines/
    charmcraft.yaml
    pyproject.toml
    poetry.lock
    # [...]
Example common/pyproject.toml
[project]
name = "common"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = [
]

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

Step 1: Add local package to charm dependencies

Repeat this step for each charm that depends on the local package.

poetry add ../common --editable

Example pyproject.toml

[tool.poetry.dependencies]
common = {path = "../common", develop = true}

Step 2: Install charmcraftlocal in charmcraft.yaml

Install charmcraftlocal in the poetry-deps charmcraft.yaml part.

Example charmcraft.yaml

parts:
  poetry-deps:
    plugin: nil
    override-build: |
      # [...]
      "$HOME/.local/bin/uv" tool install --no-python-downloads charmcraftlocal

To install with pipx instead of uv, use pipx install charmcraftlocal

Step 3: Call charmcraftlocal in charmcraft.yaml

Run charmcraftlocal update-lock before poetry export runs in the charmcraft.yaml part with plugin: poetry

Example charmcraft.yaml

parts:
  # [...]
  charm-poetry:
    plugin: poetry
    after:
      - poetry-deps
    override-build: |
      # [...]
      "$HOME/.local/bin/charmcraftlocal" update-lock -v

      craftctl default
      # [...]

Step 4: Pack charm

ccl pack

How it works

Currently, during charmcraft pack, charmcraft can only access files in the directory that contains charmcraft.yaml.

charmcraftlocal pack

  • searches (the charm's) pyproject.toml for local Python dependencies,
  • copies them to the charm directory,
  • and calls charmcraft pack

charmcraftlocal update-lock (called by charmcraft pack)

  • searches (the charm's) pyproject.toml for local Python dependencies
  • and calls Poetry to update pyproject.toml and poetry.lock to reference the copied package(s)

Why does charmcraftlocal need to be called in charmcraft.yaml?

In the first prototype of charmcraftlocal

  • only ccl pack needed to be called,
  • ccl pack called Poetry to update pyproject.toml and poetry.lock,
  • and ccl update-lock did not exist

The design was changed to maintain compatibility with tooling that expects

  • one charm per git repository,
  • charmcraft.yaml located at the root of the git repository,
  • and charmcraft pack to successfully build the charm

To maintain compatibility with that tooling, the ccl mirror command automates the creation and updates of "mirror" git repositories that meet the above requirements.

For example, for a git repository with this directory layout

common/
    # Local Python package with shared code
    pyproject.toml
    common/
        __init__.py
kubernetes/
    charmcraft.yaml
    pyproject.toml
    poetry.lock
    # [...]
machines/
    charmcraft.yaml
    pyproject.toml
    poetry.lock
    # [...]

ccl mirror can be used to create two "mirror" repositories—

one for kubernetes

common/
    # Local Python package with shared code
    pyproject.toml
    common/
        __init__.py
charmcraft.yaml
pyproject.toml
poetry.lock
# [...]

and one for machines

common/
    # Local Python package with shared code
    pyproject.toml
    common/
        __init__.py
charmcraft.yaml
pyproject.toml
poetry.lock
# [...]

git-filter-repo is used to create these "mirror" repositories. In order to preserve commit history while avoiding merge conflicts, pyproject.toml and poetry.lock must not be modified between the source repository and the "mirror" repositories.

Therefore, pyproject.toml and poetry.lock are modified at build time by calling ccl update-lock in charmcraft.yaml. (This approach enables the "mirror" repositories to be successfully built with charmcraft pack.)

Metadata

Release files for charmcraftlocal 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for charmcraftlocal 0.4.0
File Size Uploaded Provenance
charmcraftlocal-0.4.0.tar.gz 11.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for charmcraftlocal 0.4.0
File Interpreter ABI Platform
charmcraftlocal-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / charmcraftlocal-0.4.0.tar.gz

Download URL charmcraftlocal-0.4.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
de8f011d9d2073ac4719e57e2159ca64afe0b29b86c96b6f29a4dec1d1bcd318
BLAKE2b-256 checksum
How to use checksums
7567c00f94b32d10b6f27437af61e7e1f770a0ab256418656391378552e78248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release files / charmcraftlocal-0.4.0-py3-none-any.whl

Download URL charmcraftlocal-0.4.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
137d05ac5fee7592947b40e1bc9bd2f947e75dc9312407a3ae7a3fee2f08ea12
BLAKE2b-256 checksum
How to use checksums
46fc5cade4cc95a431be881ec4d3101689d68b30c698c24f9df7def4972ca70f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Security for charmcraftlocal 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for charmcraftlocal-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page