-
Notifications
You must be signed in to change notification settings - Fork 20
Charmcraft wrapper #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arturo-seijas
wants to merge
36
commits into
main
Choose a base branch
from
charmcraft-wrapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Charmcraft wrapper #964
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
5011a3d
Add supercharm wrapper
arturo-seijas 7b6b6c2
Add context
arturo-seijas 9c9244f
Refactor
arturo-seijas 6686f79
Remove boilerplate
arturo-seijas 72a7bf6
changelog
arturo-seijas fca895f
Merge branch 'main' into charmcraft-wrapper
arturo-seijas d9ef610
Update workflows
arturo-seijas 53e2712
Simplify
arturo-seijas 1e8e9be
Rename package
arturo-seijas b20d063
fix linting
arturo-seijas aba15b4
changelog
arturo-seijas 43a618e
Fix install
arturo-seijas 3c0a8ee
Fix install
arturo-seijas 2e75454
Fix installation
arturo-seijas d1b00a9
Fix installation
arturo-seijas 825ee2a
Fix installation
arturo-seijas 296ac92
Fix installation
arturo-seijas ac765d7
Merge branch 'main' into charmcraft-wrapper
arturo-seijas f92f679
build
arturo-seijas 2c664fe
Fix gitignore
arturo-seijas b33fe69
Fix gitignore
arturo-seijas a5e2953
Fix gitignore
arturo-seijas fa3ee60
rename
arturo-seijas 743c111
build
arturo-seijas 27e1f96
fix checkout
arturo-seijas 0a59491
rocks
arturo-seijas 0fd3581
build
arturo-seijas 7108b1e
changelog
arturo-seijas 94b63cd
headers
arturo-seijas ffee6e8
Apply suggestions from code review
arturo-seijas b0d586c
try local install
arturo-seijas 14c24c9
fix ref
arturo-seijas fd60699
change ref
arturo-seijas 0170c1b
Merge remote-tracking branch 'origin/main' into charmcraft-wrapper
arturo-seijas 4a070c6
fix changelog
arturo-seijas 637400b
Merge branch 'main' into charmcraft-wrapper
arturo-seijas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| build | ||
| *.egg-info | ||
| **/__pycache__/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # superbuild | ||
|
|
||
| `superbuild` is a thin Python wrapper around [charmcraft](https://juju.is/docs/sdk/charmcraft). | ||
| It ensures `charmcraft` is installed on the machine and transparently forwards all arguments to it, | ||
| with one extra convenience: a `--build-context` option that lets you supply an external directory | ||
| of source files to include in the build without modifying your project tree. | ||
|
|
||
| ## Features | ||
|
|
||
| - Auto-installs the latest `charmcraft` via `snap` if it is not already present. | ||
| - Accepts an optional `--build-context <dir>` argument (see below). | ||
| - All other arguments and flags are passed through to `charmcraft` unchanged. | ||
| - After the build, any `.charm` files whose name matches the `name` key in `charmcraft.yaml` | ||
| are copied back to the current working directory automatically. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Python 3.8+ | ||
| - `snap` (for automatic `charmcraft` installation) | ||
| - `pyyaml` (installed automatically as a dependency) | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install ./superbuild | ||
| ``` | ||
|
|
||
| Or, for development: | ||
|
|
||
| ```bash | ||
| pip install -e ./superbuild | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| superbuild [--build-context <dir>] <charmcraft command and args> | ||
| ``` | ||
|
|
||
| ### Without `--build-context` | ||
|
|
||
| `superbuild` behaves exactly like calling `charmcraft` directly: | ||
|
|
||
| ```bash | ||
| superbuild pack | ||
| superbuild version | ||
| superbuild upload my-charm_ubuntu-22.04-amd64.charm | ||
| ``` | ||
|
|
||
| ### With `--build-context` | ||
|
|
||
| Provide a directory whose contents will be merged with the `charmcraft.yaml` from the current | ||
| working directory into a temporary build directory. This is useful when your source files live | ||
| separately from your charm metadata. | ||
|
|
||
| ```bash | ||
| superbuild --build-context ./src pack | ||
| ``` | ||
|
|
||
| What happens internally: | ||
|
|
||
| 1. A temporary directory is created. | ||
| 2. `charmcraft.yaml` from the **current working directory** (if present) is copied in. | ||
| 3. All files and subdirectories from `--build-context` are copied in alongside it. | ||
| 4. `charmcraft` is executed with the remaining arguments inside that temporary directory. | ||
| 5. Any resulting `.charm` files whose filename starts with the charm `name` are copied back | ||
| to the current working directory. | ||
| 6. The temporary directory is cleaned up. | ||
|
|
||
| If `--build-context` is omitted, the current working directory is used as the context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2026 Canonical Ltd. | ||
| # See LICENSE file for licensing details. | ||
|
|
||
| [build-system] | ||
arturo-seijas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| requires = ["setuptools>=61"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "superbuild" | ||
| version = "0.1.0" | ||
| description = "Thin wrapper that ensures charmcraft is installed and forwards all arguments to it" | ||
| requires-python = ">=3.8" | ||
| dependencies = ["pyyaml"] | ||
|
|
||
| [tool.pytest.ini_options] | ||
| testpaths = ["tests"] | ||
|
|
||
| [project.scripts] | ||
| superbuild = "superbuild.main:main" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Copyright 2025 Canonical Ltd. | ||
| # See LICENSE file for licensing details. | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.