Skip to main content

canonicalwebteam.launchpad

Classes for triggering builds of snaps and Ubuntu images through the Launchpad API.

Usage

Local development

For local development, it's best to test this module with one of our website projects like ubuntu.com. For more information, follow this guide (internal only).

SnapBuilder

from canonicalwebteam.launchpad import SnapBuilder

snap_builder = SnapBuilder(
    username="build.snapcraft.io",
    token=os.getenv("SNAP_BUILDER_TOKEN"),
    secret=os.getenv("SNAP_BUILDER_SECRET"),
)

snap_name = "new-test-snap"
git_repo = "https://github.com/build-staging-snapcraft-io/test1"
snap_builder.create_snap(snap_name, git_repo)

new_snap = snap_builder.get_snap_by_store_name("new-test-snap")

create_snap authorizes store uploads using a root macaroon (typically obtained from the store's package_upload ACL endpoint). If that macaroon carries a third-party (SSO) caveat, Launchpad needs the matching discharge_macaroon as well, otherwise it will accept the authorization but never actually be able to upload builds — leaving every build stuck as "Unscheduled" ("Won't release") with no error surfaced:

snap_builder.create_snap(
    snap_name, git_repo, macaroon, discharge_macaroon=discharge_macaroon
)

Snaps that were created before a discharge macaroon was available can be repaired without recreating them, using complete_snap_authorization:

snap_builder.complete_snap_authorization(
    lp_snap_name, macaroon, discharge_macaroon=discharge_macaroon
)

ImageBuilder

from canonicalwebteam.launchpad import ImageBuilder

image_builder = ImageBuilder(
    username="image.build",
    token=os.getenv("IMAGE_BUILDER_TOKEN"),
    secret=os.getenv("IMAGE_BUILDER_SECRET"),
)

image_builder.build_image(
    board="cm3", system="core16", snaps=["code", "toto"]
)

Test fixtures

Tests check calls against fixtures representing the Launchpad API. These fixtures are generated using vcrpy, based on real calls to the API when the test was first run.

To new tests that rely on new API responses, or if we need to regenerate existing fixtures because the API has changed, the secrets need to be provided to authenticate with the API as follows:

export SNAP_BUILDER_TOKEN={token}
export SNAP_BUILDER_SECRET={secret}
export IMAGE_BUILDER_TOKEN={token}
export IMAGE_BUILDER_SECRET={secret}

rm tests/cassettes/...  # Remove any fixtures you need to regenerate

./setup.py test  # Run tests again to regenerate fixtures

Metadata

Release files for canonicalwebteam.launchpad 0.11.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 canonicalwebteam.launchpad 0.11.0
File Size Uploaded Provenance Actions
canonicalwebteam_launchpad-0.11.0.tar.gz 8.3 kB Without provenance Details for canonicalwebteam_launchpad-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for canonicalwebteam.launchpad 0.11.0
File Interpreter ABI Platform Actions
canonicalwebteam_launchpad-0.11.0-py3-none-any.whl Python 3 none any Details for canonicalwebteam_launchpad-0.11.0-py3-none-any.whl

Total release size: 17.6 kB

Release files / canonicalwebteam_launchpad-0.11.0.tar.gz

Download URL canonicalwebteam_launchpad-0.11.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
71ba53bd21352de8922ed4bde39fff35b2b04e7d42ee5c1722c7cc2d1aeb41c0
BLAKE2b-256 checksum
How to use checksums
9019856f53a8847301aa68376e6df5127b393a7a022b5d985cee4afa8760f834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / canonicalwebteam_launchpad-0.11.0-py3-none-any.whl

Download URL canonicalwebteam_launchpad-0.11.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e46890635a7cb06b236a3c22edec6f6c0adacbaf366b876240d3c6302b338060
BLAKE2b-256 checksum
How to use checksums
95fad8492773bbfca76300f5923f0eeda67d6a36317f344dce9bad6c914ae182
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Security for canonicalwebteam.launchpad 0.11.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files No provenance

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