Skip to content

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

Merged
normanlorrain merged 7 commits into
mainfrom
pyproject-uv-lock
Jun 5, 2026
Merged

Use best-practice pyproject.toml, and uv for managing dependencies#124
normanlorrain merged 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 ?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@normanlorrain normanlorrain May 26, 2026

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.

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

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.

@normanlorrain was this addressed in PR #128 which installs all the dependencies in the requirements file and not just mkdocs?

@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

@mrbiggred mrbiggred left a comment

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.

@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
Comment thread docker-compose.yml
Comment thread docker-entrypoint.sh Outdated
Comment thread pyproject.toml Outdated
@normanlorrain normanlorrain requested a review from mrbiggred May 27, 2026 00:22

@mrbiggred mrbiggred left a comment

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 put a comment in conversation about CI still using pip.

https://github.com/weeklydevchat/weeklydevchat.github.io/pull/124/changes#r3304918902

Did PR #128 help with this issue? In either case I'm happy to merge this as is and make any CI changes in another PR if needed.

@normanlorrain normanlorrain merged commit af1e8f5 into main Jun 5, 2026
3 checks passed
@normanlorrain normanlorrain deleted the pyproject-uv-lock branch June 5, 2026 01:56
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