Skip to main content

charmlibs-snap

snap manages snaps on the machine a charm runs on, by talking to snapd over its REST API. Function names, arguments, and error behaviour follow the snap command line, so what you know from the CLI carries over.

To install, add charmlibs-snap to your Python dependencies. Then in your Python code, import as:

from charmlibs import snap

See the reference documentation for more.

Upgrading from 1.x? Version 2.0 is a rewrite with a new API -- see how to migrate from 1.x to 2.0. This README and the library docs cover the 2.x series; for 1.x, see the snap-v1.0.1.post0 tag.

Getting started

Every operation is a module-level function that takes the snap's name. To make sure a snap is installed on a particular channel, and refresh it if an update is available:

from charmlibs import snap

snap.ensure_installed('lxd', '5.21/stable')

ensure_installed installs the snap if it's absent, refreshes it if it's on the wrong channel or revision, and otherwise refreshes it if an update is available. It returns a truthy value if anything changed.

Configure the snap and manage its services:

snap.set('lxd', {'core.https_address': ':8443'})
snap.get_one('lxd', 'core.https_address')  # ':8443'
snap.start('lxd', 'daemon', enable=True)

Query the installed snap's state with list_one, which returns an InstalledInfo:

info = snap.list_one('lxd')
info.tracking  # '5.21/stable'
info.revision  # '33110'
info.version  # '5.21.3'

Install or refresh to a specific revision, and hold the snap so that automatic refreshes don't move it:

snap.refresh('lxd', '5.21/stable', revision=33110)
snap.hold('lxd')

Metadata

Release files for charmlibs-snap 2.2.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 charmlibs-snap 2.2.0
File Size Uploaded Provenance Actions
charmlibs_snap-2.2.0.tar.gz 130.5 kB With provenance Details for charmlibs_snap-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for charmlibs-snap 2.2.0
File Interpreter ABI Platform Actions
charmlibs_snap-2.2.0-py3-none-any.whl Python 3 none any Details for charmlibs_snap-2.2.0-py3-none-any.whl

Total release size: 172.0 kB

Release files / charmlibs_snap-2.2.0.tar.gz

Download URL charmlibs_snap-2.2.0.tar.gz
Size 130.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b97dc8737f992bfbaf8f30df0cc0a47cb42c5b9887ecb6c29c0eb8e0789e367b
BLAKE2b-256 checksum
How to use checksums
aeb21f48a15ffeda9172323e7935786153b519040b8a3ae82f7d2e3c3b8937b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Release files / charmlibs_snap-2.2.0-py3-none-any.whl

Download URL charmlibs_snap-2.2.0-py3-none-any.whl
Size 41.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d88b171a4974a9a0b006f971d640d29917efea2e10d115a6e9f689be7d97efde
BLAKE2b-256 checksum
How to use checksums
2d7bd866b7415580fe28365548e132c3de66518ba8e0d4b99d91ffd5c67d664a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 18, 2026.

Transparency log

Security for charmlibs-snap 2.2.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for charmlibs_snap-2.2.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 Nov 18, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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