feat: uv support for Flask, Django and FastAPI extensions - #1308
Draft
Thanhphan1147 wants to merge 6 commits into
Draft
feat: uv support for Flask, Django and FastAPI extensions#1308Thanhphan1147 wants to merge 6 commits into
Thanhphan1147 wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds uv-based build support to the Flask, Django, and FastAPI framework extensions so that projects with both uv.lock and pyproject.toml use the uv plugin for dependency installation, while preserving existing pip/python plugin behavior when uv.lock is absent.
Changes:
- Add
uvproject detection + validation helpers (uses_uv,validate_uv_lockfile) and wire them into Flask/Django/FastAPI extension validation/part generation. - Switch dependency parts to use the
uvplugin when appropriate, injectinggunicorn/uvicornviaoverride-buildfor locked (uv) projects. - Add unit tests and documentation sections describing
uvbehavior for all three extensions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/extensions/test_python_utils.py | New unit tests for uv detection/validation helpers. |
| tests/unit/extensions/test_gunicorn.py | Adds Flask/Django uv-project tests and error-case coverage. |
| tests/unit/extensions/test_fastapi.py | Adds FastAPI uv-project tests and error-case coverage. |
| rockcraft/extensions/gunicorn.py | Uses uv plugin for deps when uv.lock+pyproject.toml are present; validates lockfile pairing. |
| rockcraft/extensions/fastapi.py | Uses uv plugin for deps when uv.lock+pyproject.toml are present; skips requirements.txt checks for uv projects. |
| rockcraft/extensions/_python_utils.py | Introduces uses_uv() and validate_uv_lockfile() helpers. |
| docs/reference/extensions/flask-framework.rst | Documents uv project behavior for Flask extension. |
| docs/reference/extensions/django-framework.rst | Documents uv project behavior for Django extension. |
| docs/reference/extensions/fastapi-framework.rst | Documents uv project behavior for FastAPI extension. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+202
to
+204
| return (project_root / "uv.lock").exists() and ( | ||
| project_root / "pyproject.toml" | ||
| ).exists() |
Comment on lines
+213
to
+215
| if (project_root / "uv.lock").exists() and not ( | ||
| project_root / "pyproject.toml" | ||
| ).exists(): |
Signed-off-by: Phan Trung Thanh <trung.thanh.phan@canonical.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
uvbuild support to the Flask, Django and FastAPI framework extensions. When a project ships bothuv.lockandpyproject.toml, the extension builds the dependencies part with theuvplugin (uv sync) instead of thepythonplugin, and injects the server dependency (gunicorn~=23.0/uvicorn) via a post-buildoverride-buildstep since the lockfile is the source of truth.Behavior
uv.lock+pyproject.toml→ build withuvplugin.pyproject.tomlonly → fall back to thepython(pip) plugin (unchanged).uv.lockwithoutpyproject.toml→ pack fails: "the plugin requires both uv.lock and pyproject.toml to be present".requirements.txtfor uv projects.Testing
make lintpasses; extension unit tests pass.gunicorn 23.0.0.