|
| 1 | +# Copyright 2025 Canonical Ltd. |
| 2 | +# See LICENSE file for licensing details. |
| 3 | + |
| 4 | +type: charm |
| 5 | +platforms: |
| 6 | + |
| 7 | + |
| 8 | +name: cassandra |
| 9 | +summary: | |
| 10 | + Charmed Apache Cassandra Operator |
| 11 | +description: | |
| 12 | + Apache Cassandra is a free and open-source database management system designed to handle large volumes of data across multiple commodity servers. This charm deploys and operate Apache Cassandra on a VM machine environment. |
| 13 | + Apache Cassandra is a free and open-source software project by the Apache Software Foundation. |
| 14 | + Users can find out more at the [Apache Cassandra project page](https://cassandra.apache.org/_/index.html). |
| 15 | +
|
| 16 | +charm-libs: |
| 17 | + - lib: operator_libs_linux.snap |
| 18 | + version: "2" |
| 19 | + - lib: data_platform_libs.data_models |
| 20 | + version: "1" |
| 21 | + - lib: data_platform_libs.data_interfaces |
| 22 | + version: "0" |
| 23 | + |
| 24 | +config: |
| 25 | + options: |
| 26 | + profile: |
| 27 | + # TODO: description |
| 28 | + type: string |
| 29 | + default: production |
| 30 | + cluster_name: |
| 31 | + # TODO: description |
| 32 | + type: string |
| 33 | + default: Test Cluster |
| 34 | + |
| 35 | +peers: |
| 36 | + cassandra-peers: |
| 37 | + interface: cassandra_peers |
| 38 | + |
| 39 | +parts: |
| 40 | + # "poetry-deps" part name is a magic constant |
| 41 | + # https://github.com/canonical/craft-parts/pull/901 |
| 42 | + poetry-deps: |
| 43 | + plugin: nil |
| 44 | + build-packages: |
| 45 | + - curl |
| 46 | + override-build: | |
| 47 | + # Use environment variable instead of `--break-system-packages` to avoid failing on older |
| 48 | + # versions of pip that do not recognize `--break-system-packages` |
| 49 | + # `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04 |
| 50 | + PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest |
| 51 | +
|
| 52 | + # Use uv to install poetry so that a newer version of Python can be installed if needed by poetry |
| 53 | + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh # renovate: charmcraft-uv-latest |
| 54 | + # poetry 2.0.0 requires Python >=3.9 |
| 55 | + if ! "$HOME/.local/bin/uv" python find '>=3.9' |
| 56 | + then |
| 57 | + # Use first Python version that is >=3.9 and available in an Ubuntu LTS |
| 58 | + # (to reduce the number of Python versions we use) |
| 59 | + "$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04 |
| 60 | + fi |
| 61 | + "$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.0 --with poetry-plugin-export==1.8.0 # renovate: charmcraft-poetry-latest |
| 62 | +
|
| 63 | + ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry |
| 64 | + # "charm-poetry" part name is arbitrary; use for consistency |
| 65 | + # Avoid using "charm" part name since that has special meaning to charmcraft |
| 66 | + charm-poetry: |
| 67 | + # By default, the `poetry` plugin creates/stages these directories: |
| 68 | + # - lib, src |
| 69 | + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78) |
| 70 | + # - venv |
| 71 | + # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95 |
| 72 | + # https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270) |
| 73 | + plugin: poetry |
| 74 | + source: . |
| 75 | + after: |
| 76 | + - poetry-deps |
| 77 | + poetry-export-extra-args: ["--only", "main,charm-libs"] |
| 78 | + poetry-pip-extra-args: ["--only-binary=cassandra-driver"] |
| 79 | + build-packages: |
| 80 | + - libffi-dev # Needed to build Python dependencies with Rust from source |
| 81 | + - libssl-dev # Needed to build Python dependencies with Rust from source |
| 82 | + - pkg-config # Needed to build Python dependencies with Rust from source |
| 83 | + - libev-dev |
| 84 | + override-build: | |
| 85 | + # Workaround for https://github.com/canonical/charmcraft/issues/2068 |
| 86 | + # rustup used to install rustc and cargo, which are needed to build Python dependencies with Rust from source |
| 87 | + if [[ "$CRAFT_PLATFORM" == [email protected]:* || "$CRAFT_PLATFORM" == [email protected]:* ]] |
| 88 | + then |
| 89 | + snap install rustup --classic |
| 90 | + else |
| 91 | + apt-get install rustup -y |
| 92 | + fi |
| 93 | +
|
| 94 | + # If Ubuntu version < 24.04, rustup was installed from snap instead of from the Ubuntu |
| 95 | + # archive—which means the rustup version could be updated at any time. Print rustup version |
| 96 | + # to build log to make changes to the snap's rustup version easier to track |
| 97 | + rustup --version |
| 98 | +
|
| 99 | + # rpds-py (Python package) >=0.19.0 requires rustc >=1.76, which is not available in the |
| 100 | + # Ubuntu 22.04 archive. Install rustc and cargo using rustup instead of the Ubuntu archive |
| 101 | + rustup set profile minimal |
| 102 | + rustup default 1.87.0 # renovate: charmcraft-rust-latest |
| 103 | +
|
| 104 | + craftctl default |
| 105 | + # Include requirements.txt in *.charm artifact for easier debugging |
| 106 | + cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt" |
| 107 | +
|
| 108 | + # "files" part name is arbitrary; use for consistency |
| 109 | + files: |
| 110 | + plugin: dump |
| 111 | + source: . |
| 112 | + stage: |
| 113 | + - LICENSE |
0 commit comments