Skip to content
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

fix(flask): use rustup snap #1744

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions charmcraft/extensions/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ def _get_root_snippet(self) -> dict[str, Any]:
"grafana-dashboard": {"interface": "grafana_dashboard"},
},
"config": {"options": {**self._WEBSERVER_OPTIONS, **self.options}},
"parts": {"charm": {"plugin": "charm", "source": "."}},
"parts": {
"charm": {
"plugin": "charm",
"source": ".",
"build-snaps": ["rustup"], # Needed to build pydantic.
}
},
}

@override
Expand Down Expand Up @@ -225,12 +231,6 @@ def is_experimental(base: tuple[str, ...] | None) -> bool: # noqa: ARG004
"""Check if the extension is in an experimental state."""
return False

@override
def get_parts_snippet(self) -> dict[str, Any]:
"""Return the parts to add to parts."""
# rust is needed to build pydantic-core, a dependency of flask.
return {"flask-framework/rust-deps": {"plugin": "nil", "build-packages": ["cargo"]}}


class DjangoFramework(_GunicornBase):
"""Extension for 12-factor Django applications."""
Expand Down
11 changes: 7 additions & 4 deletions tests/extensions/test_gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def flask_input_yaml_fixture():
"options": {**FlaskFramework.options, **FlaskFramework._WEBSERVER_OPTIONS}
},
"parts": {
"charm": {"plugin": "charm", "source": "."},
"flask-framework/rust-deps": {"plugin": "nil", "build-packages": ["cargo"]},
"charm": {"plugin": "charm", "source": ".", "build-snaps": ["rustup"]},
},
"peers": {"secret-storage": {"interface": "secret-storage"}},
"provides": {
Expand Down Expand Up @@ -121,7 +120,7 @@ def flask_input_yaml_fixture():
"config": {
"options": {**DjangoFramework.options, **DjangoFramework._WEBSERVER_OPTIONS}
},
"parts": {"charm": {"plugin": "charm", "source": "."}},
"parts": {"charm": {"plugin": "charm", "source": ".", "build-snaps": ["rustup"]}},
"peers": {"secret-storage": {"interface": "secret-storage"}},
"provides": {
"metrics-endpoint": {"interface": "prometheus_scrape"},
Expand Down Expand Up @@ -255,4 +254,8 @@ def test_handle_charm_part(flask_input_yaml, tmp_path):
apply_extensions(tmp_path, flask_input_yaml)
del flask_input_yaml["parts"]
applied = apply_extensions(tmp_path, flask_input_yaml)
assert applied["parts"]["charm"] == {"plugin": "charm", "source": "."}
assert applied["parts"]["charm"] == {
"plugin": "charm",
"source": ".",
"build-snaps": ["rustup"],
}
8 changes: 5 additions & 3 deletions tests/spread/commands/init-flask-framework/task.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
summary: test charmcraft init with flask-framework profile
priority: 500 # This builds pydantic, so do it early
kill-timeout: 75m # Because it builds pydantic, it takes a long time.
systems:
# We only need to run this test once, and it takes a long time.
- ubuntu-22.04-64

execute: |
unset CHARMCRAFT_STORE_API_URL
unset CHARMCRAFT_UPLOAD_URL
unset CHARMCRAFT_REGISTRY_URL
mkdir -p test-init
cd test-init
charmcraft init --profile flask-framework
Expand Down
Loading