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.0.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.0.0
File Size Uploaded
charmlibs_snap-2.0.0.tar.gz 125.4 kB Details

Built distribution (wheel)

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

Total release size: 163.9 kB

Release files / charmlibs_snap-2.0.0.tar.gz

Download URL charmlibs_snap-2.0.0.tar.gz
Size 125.4 kB
Tags Source
SHA-256 checksum
How to use checksums
82bc863919614436bf4e8e38cedaa4d809c3d4e1eedab10b2eeb97006116cd29
BLAKE2b-256 checksum
How to use checksums
d0f1b1af81b093f4b94f957a2d2efb20b78975f615a6384d44917c633f77ce82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

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

Download URL charmlibs_snap-2.0.0-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e479163ede22f9ab4b66adead2d4ce4cdc6eb77f36f88c50c4d3d3b075da040
BLAKE2b-256 checksum
How to use checksums
60d965d7e73532c50f2533b8f1a735894b5d260202f60d5ab05e367b93382e13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

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