-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate version using setuptools scm (#534)
* Migrate setup.py -> pyproject.toml * Update mk-venv to use pyproject.toml * Migrate setup.py -> pyproject.py * Minor: Added missing fields to metadata * Migrate somekeys from pyproject.toml to setup.cfg This was done because on older versions of pip the previous setup does not work (even though it does not report any error). The previous version seems to work on `pip 23.1.2` but it does not install correctly at all (mainly: missing bins and missing package name) Also: sign was imported from main * Updated metabox config checking for source * Add isolated_build to tox.ini * Fixed install in tox.ini and updated run command * Removed unecessary editable install * Fixed install and run scripts * Avoid scm versioning in tox runs * Move scm bodge to the correct python version * Port dependencies to setup.cfg as well * Bodge: Install as dep requests-unixsocked in py3.6 * Port bodge to 3.5 * Use checkbox_ng.__version__ without hacking path * Fix relative install requirements.txt * Avoid dumping the full version number in the doc header * Remove outdated references to setup.py * Support multidigits tags * Re-include setup.cfg options field lost in rebase * Updated authors * Added pybuild plugin pyproject to build-req * Fix snap builds scm (#578) * Duplicated dependencies in pyproject.toml * Avoid copying by symlink in prepare.sh * Revert "Avoid copying by symlink in prepare.sh" This reverts commit 4812099. * Dump version in text file within series dir * Added bodges for setup.py and pretend version This was done to be backward compatible with any version that does not support pyproject.toml. Also, when building a snap via snapcraft we have no .git, so we need to dump the version before and load it via the file "pretending it" * Missing pipe concats commands breaking build * Fix version path * Fix setup scripts from setup.cfg -> pyproject.toml * Escape scripts name * Recovered all entrypoints not just scripts * Removed dynamic from startpoints * Quote names with spaces * Ported fix to series20 * Fixed definition of stress-ng and updated var export Amend: recovered tag, git init * Better setup_scm bodge * Backported to core16 * Ported to core18 * Fixed moved lib in series22 * Bodge 18 to support pyproject * Make dependencies local to jobs * Full build for series16 snap * Small guide on how to build checkbox-core-snap * Adopt version from version file * Fixed scm version of libraries * Update grep to support semantic versioning * Removed version calculation from github job * Dump version using setuptools_scm * adopt-info for checkbox-snap and checkbox-classic-snap * Minor: Info about operation being done in prepare.sh * Xenial support * Setuptools scm deb daily (#588) * Remove bumpversion configs and workflows * Pass the version generated by setuptools_scm to deb daily build recipes * Fixed line len to max 80 * Explained how to use the lxd backend and reordering * Updated requirements * Ensure that setup.py has the SETUPTOOLS_PRETEND_VERSION envvar * Ported envvar fix to 20 * Updated README.md as per feedback * Document versioning via setuptools_scm in prepare.sh * Minor: call launcher checkbox snap frontend and not user * Removed hack in requirements.txt for readthedocs.yaml Minor: Fixed typo in README.md --------- Co-authored-by: Sylvain Pineau <sylvain.pineau@canonical.com>
- Loading branch information
Showing
47 changed files
with
668 additions
and
499 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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,147 @@ | ||
# Building checkbox-core-snap | ||
This snap is the core reusable part of checkbox, it includes all the utilities | ||
and some core providers. The snap can be built for multiple | ||
[base snaps](https://snapcraft.io/docs/base-snaps). Each recipe is in a `seriesXX` | ||
directory where `XX` is the base snap. For instance `series22` contains | ||
the `core22 or jammy` snap. | ||
|
||
## Building guide | ||
This section covers how to build the snap via either the `multipass` or the | ||
`lxd` backend. This guide will focus on the latter | ||
but with small adjustments can be used for the former. Also, this guide will | ||
build the `series22` snap, adjust the commands to build any other. | ||
|
||
In order to build the snap you are going to need the following: | ||
1. **snapcraft:** Installed via `snap install snapcraft --classic` or | ||
`snap install snapcraft --classic --channel=4.x` for series16 | ||
2. **python3:** Installed via `apt` or any other packaging solution | ||
3. **setuptools_scm:** Installed via pip | ||
4. **rsync:** Installed via apt or any other packaging solution | ||
|
||
After installing all the dependencies do the following: | ||
``` | ||
> git clone https://github.com/canonical/checkbox | ||
> cd checkbox/checkbox-core-snap/ | ||
> ./prepare.sh series22 | ||
> cd series22 | ||
``` | ||
|
||
> Note: `prepare.sh` will prepare the series creating the build environment, | ||
> refer to its output for further detail | ||
Finally build the snap with: | ||
``` | ||
> snapcraft --use-lxd | ||
``` | ||
|
||
If the build has failed, check either the **Building guide for debugging**, if | ||
it completed succesfully, refer to **Testing the build**. | ||
|
||
## Testing the build | ||
To test the build one must install it and see if the content is correct. | ||
One way to do it is the following: | ||
|
||
```bash | ||
> snap install checkbox22_(version)_(arch).snap --dangerous | ||
``` | ||
Now we have installed the core snap, but we cannnot use it directly. To use it | ||
we need a frontend snap. | ||
```bash | ||
# Note: install the correct channel for your series | ||
> snap install checkbox --classic --channel=22.04 | ||
``` | ||
To test the checkbox snap, you can try to run test plans as follows. | ||
For example, you may want to run the smoke test plan. | ||
``` | ||
> checkbox.checkbox_cli | ||
``` | ||
|
||
## Building for debugging | ||
To build the checkbox core snap for debugging you might find | ||
`snapcraft --destructive-mode` executed in a single-use container a handy trick | ||
(see [Faster snap development – additional tips and tricks](https://snapcraft.io/blog/faster-snap-development-additional-tips-and-tricks) | ||
for more info). | ||
Below you will find build steps for the series22 snap as an example | ||
(changes needed for earlier series pointed out where applicable). | ||
|
||
The destructive mode is useful for debugging a build because of incremental | ||
build time: with direct host system one can quickly iterate on the environment | ||
installing packages, changing versions or editing the recipe, without restarting | ||
every build from scratch afterwards. | ||
|
||
### Container configuration | ||
Let's begin by creating the container and installing the needed packages. | ||
```bash | ||
# First, create the container | ||
# Note: Always use the version of ubuntu for the snap you | ||
# are building, series22 -> ubuntu22.04 (jammy) | ||
(host) > lxd launch ubuntu:22.04 jammy | ||
(host) > lxd exec jammy bash | ||
# Once in the container install snapcraft. | ||
# Note: For series16 you will need snapcraft4.x, to install | ||
# it use run: | ||
# snap install snapcraft --classic --channel=4.x | ||
(jammy)> snap install snapcraft --classic | ||
# Now clone the checkbox repository | ||
(jammy)> git clone https://github.com/canonical/checkbox | ||
(jammy)> apt install python3-setuptools-scm git snapd | ||
``` | ||
If you are debugging a build, this is a good step to make a backup of the | ||
environment, so that you don't need to repeat the above steps if something | ||
goes wrong. | ||
```bash | ||
(jammy)> exit | ||
(host) > lxd snapshot jammy backup | ||
``` | ||
If at any point you need to rollback to this backup run | ||
```bash | ||
(host) > lxd restore jammy backup | ||
(host) > lxd exec jammy bash | ||
# This you may want to do if you made any updates to the repo | ||
# in the meantime | ||
(jammy)> (cd checkbox && git pull) | ||
``` | ||
### Running the build | ||
Now let's launch the actual build | ||
```bash | ||
(jammy)> cd checkbox/checkbox-core-snap | ||
# For another series, change the parameter accordingly | ||
(jammy)> ./prepare.sh series22 | ||
(jammy)> snapcraft --destructive-mode | ||
``` | ||
The previous will either create a `checkbox22_(version)_(arch).snap` file or | ||
yield an error. | ||
|
||
If the build fails, refer to the **Recovering from a failure** chapter for some | ||
tips! | ||
|
||
If the build completes, refer to the **Testing the build**, remember to follow | ||
that guide from within the container you have created in this chapter! | ||
|
||
### Recovering from a failure | ||
|
||
Recovering from a failure is tricky, which is why you should create a | ||
snapshot. Most of the time you will not need it, but sometimes it will be | ||
necessary. Depending on what failed you may want to follow these strategies | ||
re-run the build: | ||
|
||
**Just re-run it:** Snapcraft will try to use cached steps for what you have | ||
done and re-do things that you have changed in the recipe. | ||
|
||
**Clean parts (partial):** You can try to remove a `part` cache. To do so run | ||
`rm -rf parts/(part_name)`. This will many problems like the part being dirty | ||
and snapcraft being unable to overwrite what is there. | ||
|
||
**Clean parts (all)**: Sometimes a parts dir in unrecoverably dirty and you | ||
may be unable to clean specifically what is broken, a symptom of this is | ||
snapcraft skipping a part thinking that it is up-to-date when it was actually | ||
changed. To do this `rm -rf parts`. | ||
|
||
**Clean all:** Sometimes cleaning `parts` is not enough, you can run | ||
`git clean -xfd`, resetting the repo to a clean state. If you do this remember | ||
you need to run `prepare.sh` again. | ||
|
||
**Reset to the snapshot:** This is also necessary sometimes, you can find the | ||
command above! | ||
|
||
|
This file contains 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 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 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
Oops, something went wrong.