Use best-practice pyproject.toml, and uv for managing dependencies#124
Use best-practice pyproject.toml, and uv for managing dependencies#124normanlorrain wants to merge 7 commits into
Conversation
|
Separate comment for discussion... |
There was a problem hiding this comment.
Pull request overview
This PR migrates the repo’s Python dependency management from requirements*.txt files to a pyproject.toml + uv workflow, and updates the Docker-based dev environment accordingly.
Changes:
- Add
pyproject.tomland a committeduv.lock; removerequirements*.in/requirements*.txt. - Update Docker Compose + entrypoint to use the
ghcr.io/astral-sh/uvimage and runuv sync/uv run. - Add a
.dockerignore(primarily to exclude local Python artifacts like.venv).
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds the uv lockfile to enable reproducible installs. |
| requirements.txt | Removed in favor of pyproject.toml/uv.lock. |
| requirements.in | Removed in favor of pyproject.toml/uv.lock. |
| requirements-dev.txt | Removed in favor of pyproject.toml/uv.lock. |
| requirements-dev.in | Removed in favor of pyproject.toml/uv.lock. |
| pyproject.toml | Defines project metadata and direct dependencies for uv to manage. |
| docker-entrypoint.sh | Switches container bootstrap from pip install -r requirements.txt to uv sync. |
| docker-compose.yml | Switches base image/cache volume and runs MkDocs via uv run. |
| .dockerignore | Ignores .venv/__pycache__/.git* when building images. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| image: ghcr.io/astral-sh/uv:python3.14-trixie-slim | ||
| working_dir: /app | ||
| entrypoint: /app/docker-entrypoint.sh | ||
| command: uv run -- mkdocs serve -a 0.0.0.0:8000 --watch-theme --livereload |
There was a problem hiding this comment.
I'd like to do this in a separate PR. @mrbiggred comments?
You are correct @normanlorrain. The following command will run a shell in the Docker container: I like adding the |
mrbiggred
left a comment
There was a problem hiding this comment.
@normanlorrain thanks upgrading from pip to uv and for adding the .dockerignore file, I always forget to create one.
I kicked off a Copilot review and will let you respond to Copilot's feedback as needed. I also added some of my own thoughts.
| image: python:3.14-slim | ||
| command: python -m mkdocs serve -a 0.0.0.0:8000 --watch-theme --livereload | ||
| entrypoint: /app/docker-entrypoint.sh | ||
| image: ghcr.io/astral-sh/uv:python3.14-trixie-slim |
There was a problem hiding this comment.
Why switch the docker image? Is there an advantage to the GitHub one?
There was a problem hiding this comment.
It has the uv tool already built into it. I should have been clear and put that in commit message.
| - .:/app | ||
| - pip-cache:/root/.cache/pip | ||
| - uv-cache:/root/.cache/uv | ||
| # Optional: protect .venv if you ever create one locally |
There was a problem hiding this comment.
I never considered having /app/.venv as volume, but it is probably a good idea, so you don't clobber your local venv.
| set -e | ||
|
|
||
| pip install -r requirements.txt | ||
| # Sync dependencies (fast thanks to uv + cache) |
There was a problem hiding this comment.
I don't think the comment about sync dependencies is needed.
| requires-python = ">=3.14" | ||
| dependencies = [ | ||
| "mkdocs-material>=9.7.0", | ||
| "pillow>=12.2.0", |
There was a problem hiding this comment.
I think pillow is only required in development to run the image compression script and not needed in production.
There was a problem hiding this comment.
Good point. I'll fix.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Python has evolved over the years, with respect to package management. The
requirements.txtfile nas now been replaced bypyproject.toml. Also,pipis losing favour to theuvtool.I'm trying to stay with best practices, so this PR makes the changes.
The docker command is the same:
docker compose up app. The docker base image changed to include the uv tool.Done with the assistance of Grok AI.
Tested on Linux Mint.