Skip to content

Use best-practice pyproject.toml, and uv for managing dependencies#124

Open
normanlorrain wants to merge 7 commits into
mainfrom
pyproject-uv-lock
Open

Use best-practice pyproject.toml, and uv for managing dependencies#124
normanlorrain wants to merge 7 commits into
mainfrom
pyproject-uv-lock

Conversation

@normanlorrain
Copy link
Copy Markdown
Contributor

Python has evolved over the years, with respect to package management. The requirements.txt file nas now been replaced by pyproject.toml. Also, pip is losing favour to the uv tool.

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.

@normanlorrain
Copy link
Copy Markdown
Contributor Author

Separate comment for discussion...
I'm not a docker expert, but I did find you can run docker compose run app bash to get to a shell prompt permitting use of the helper scripts. Perhaps there's something better @mrbiggred ?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.toml and a committed uv.lock; remove requirements*.in / requirements*.txt.
  • Update Docker Compose + entrypoint to use the ghcr.io/astral-sh/uv image and run uv 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.

Comment thread pyproject.toml Outdated
Comment thread docker-compose.yml
Comment on lines +3 to +6
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
Copy link
Copy Markdown
Contributor Author

@normanlorrain normanlorrain May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to do this in a separate PR. @mrbiggred comments?

@mrbiggred
Copy link
Copy Markdown
Member

Separate comment for discussion... I'm not a docker expert, but I did find you can run docker compose run app bash to get to a shell prompt permitting use of the helper scripts. Perhaps there's something better @mrbiggred ?

You are correct @normanlorrain. The following command will run a shell in the Docker container:

docker compose run --rm app bash

I like adding the --rm as it will remove the running container when done. You can also run one off commands in the container, such as creating a new post:

docker compose run --rm app ./create_post.sh

@mrbiggred mrbiggred added dependencies Pull requests that update a dependency file devops DevOps tasks labels May 26, 2026
Copy link
Copy Markdown
Member

@mrbiggred mrbiggred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread docker-compose.yml
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why switch the docker image? Is there an advantage to the GitHub one?

Copy link
Copy Markdown
Contributor Author

@normanlorrain normanlorrain May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has the uv tool already built into it. I should have been clear and put that in commit message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More details here.

Comment thread docker-compose.yml
- .:/app
- pip-cache:/root/.cache/pip
- uv-cache:/root/.cache/uv
# Optional: protect .venv if you ever create one locally
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never considered having /app/.venv as volume, but it is probably a good idea, so you don't clobber your local venv.

Comment thread docker-entrypoint.sh Outdated
set -e

pip install -r requirements.txt
# Sync dependencies (fast thanks to uv + cache)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the comment about sync dependencies is needed.

Comment thread pyproject.toml Outdated
requires-python = ">=3.14"
dependencies = [
"mkdocs-material>=9.7.0",
"pillow>=12.2.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pillow is only required in development to run the image compression script and not needed in production.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll fix.

normanlorrain and others added 4 commits May 26, 2026 10:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@normanlorrain normanlorrain requested a review from mrbiggred May 27, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file devops DevOps tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants