|
1 |
| -# Copyright 2023 Canonical Ltd. |
| 1 | +# Copyright 2022 Canonical Ltd. |
2 | 2 | # See LICENSE file for licensing details.
|
3 | 3 |
|
4 | 4 | type: charm
|
5 |
| -bases: |
6 |
| - - name: ubuntu |
7 |
| - channel: "20.04" |
8 |
| - architectures: [amd64] |
9 |
| - - name: ubuntu |
10 |
| - channel: "20.04" |
11 |
| - architectures: [arm64] |
12 |
| - - name: ubuntu |
13 |
| - channel: "22.04" |
14 |
| - architectures: [amd64] |
15 |
| - - name: ubuntu |
16 |
| - channel: "22.04" |
17 |
| - architectures: [arm64] |
| 5 | +platforms: |
| 6 | + ubuntu@20.04:amd64: |
| 7 | + ubuntu@20.04:arm64: |
| 8 | + |
| 9 | + ubuntu@22.04:arm64: |
| 10 | +# Files implicitly created by charmcraft without a part: |
| 11 | +# - dispatch (https://github.com/canonical/charmcraft/pull/1898) |
| 12 | +# - manifest.yaml |
| 13 | +# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259) |
| 14 | +# Files implicitly copied/"staged" by charmcraft without a part: |
| 15 | +# - actions.yaml, config.yaml, metadata.yaml |
| 16 | +# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293 |
| 17 | +# https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157) |
18 | 18 | parts:
|
19 |
| - charm: |
20 |
| - charm-strict-dependencies: true |
21 |
| - charm-binary-python-packages: |
22 |
| - - mysql-connector-python |
| 19 | + # "poetry-deps" part name is a magic constant |
| 20 | + # https://github.com/canonical/craft-parts/pull/901 |
| 21 | + poetry-deps: |
| 22 | + plugin: nil |
| 23 | + build-packages: |
| 24 | + - curl |
| 25 | + override-build: | |
| 26 | + # Use environment variable instead of `--break-system-packages` to avoid failing on older |
| 27 | + # versions of pip that do not recognize `--break-system-packages` |
| 28 | + # `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04 |
| 29 | + PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest |
| 30 | +
|
| 31 | + # Use uv to install poetry so that a newer version of Python can be installed if needed by poetry |
| 32 | + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.20/uv-installer.sh | sh # renovate: charmcraft-uv-latest |
| 33 | + # poetry 2.0.0 requires Python >=3.9 |
| 34 | + if ! "$HOME/.local/bin/uv" python find '>=3.9' |
| 35 | + then |
| 36 | + # Use first Python version that is >=3.9 and available in an Ubuntu LTS |
| 37 | + # (to reduce the number of Python versions we use) |
| 38 | + "$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04 |
| 39 | + fi |
| 40 | + "$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.1 --with poetry-plugin-export==1.9.0 # renovate: charmcraft-poetry-latest |
| 41 | +
|
| 42 | + ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry |
| 43 | + # "charm-poetry" part name is arbitrary; use for consistency |
| 44 | + # Avoid using "charm" part name since that has special meaning to charmcraft |
| 45 | + charm-poetry: |
| 46 | + # By default, the `poetry` plugin creates/stages these directories: |
| 47 | + # - lib, src |
| 48 | + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78) |
| 49 | + # - venv |
| 50 | + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95 |
| 51 | + # https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270) |
| 52 | + plugin: poetry |
| 53 | + source: . |
| 54 | + after: |
| 55 | + - poetry-deps |
| 56 | + poetry-export-extra-args: ['--only', 'main,charm-libs'] |
| 57 | + poetry-pip-extra-args: ['--only-binary', 'mysql-connector-python'] |
| 58 | + override-build: | |
| 59 | + craftctl default |
| 60 | + # Include requirements.txt in *.charm artifact for easier debugging |
| 61 | + cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt" |
| 62 | + # "files" part name is arbitrary; use for consistency |
| 63 | + files: |
| 64 | + plugin: dump |
| 65 | + source: . |
| 66 | + stage: |
| 67 | + - LICENSE |
0 commit comments