Skip to content

Commit

Permalink
fix(flask): include cargo build-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Jul 17, 2024
1 parent def89c5 commit c495875
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions charmcraft/extensions/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ 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
7 changes: 5 additions & 2 deletions tests/extensions/test_gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def flask_input_yaml_fixture():
"config": {
"options": {**FlaskFramework.options, **FlaskFramework._WEBSERVER_OPTIONS}
},
"parts": {"charm": {"plugin": "charm", "source": "."}},
"parts": {
"charm": {"plugin": "charm", "source": "."},
"flask-framework/rust-deps": {"plugin": "nil", "build-packages": ["cargo"]},
},
"peers": {"secret-storage": {"interface": "secret-storage"}},
"provides": {
"metrics-endpoint": {"interface": "prometheus_scrape"},
Expand Down Expand Up @@ -245,4 +248,4 @@ 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": "."}

0 comments on commit c495875

Please sign in to comment.