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.1.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.1.0
File Size Uploaded Provenance Actions
charmlibs_snap-2.1.0.tar.gz 127.3 kB With provenance Details for charmlibs_snap-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 167.5 kB

Release files / charmlibs_snap-2.1.0.tar.gz

Download URL charmlibs_snap-2.1.0.tar.gz
Size 127.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1897eb86c4a8d9a37aa551ac3bc5ff946bbf9dc8ec74b3839a19df0c86a8f87e
BLAKE2b-256 checksum
How to use checksums
084645a8848a02d9c2476073c7e6bcdfcd3950dc8f200b56246ebe9550a30d36
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 17, 2026.

Transparency log

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

Download URL charmlibs_snap-2.1.0-py3-none-any.whl
Size 40.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd1d2ddf27a60a01e9c5983625ac801ed19bd9b685a5a14bc342010f5d303608
BLAKE2b-256 checksum
How to use checksums
1ef8e2e00f4c2435faabf9531e49bad5256897a6ed4180db052056acbd8af650
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 17, 2026.

Transparency log

Security for charmlibs-snap 2.1.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.1.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 17, 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