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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file canonicalwebteam_launchpad-0.10.0.tar.gz.
File metadata
- Download URL: canonicalwebteam_launchpad-0.10.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf7ccee7265aaaedf9c04dea16b3f844b202b0a46ab3458855d1967f609b2cf
|
|
| MD5 |
be885dae65b46d28bb73b5163a210509
|
|
| BLAKE2b-256 |
6ca2745dad0fbe6444811bf1961be8ff6b41113774b7ecec15cac6c88d80de43
|
File details
Details for the file canonicalwebteam_launchpad-0.10.0-py3-none-any.whl.
File metadata
- Download URL: canonicalwebteam_launchpad-0.10.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b807c3a02ef77940c4eeebebb4e0f75c29277ff09a1a95f111050da9572154db
|
|
| MD5 |
6c0ec0fad71f1b07e73e49e806cd371a
|
|
| BLAKE2b-256 |
36b380ec7ddc4c702d6154f6259e328b7bea0182eaac1fe9f92fe49eae05cc2a
|