Skip to content

Commit 850e76d

Browse files
committed
WIP: Switch poetry to uv
DEPS: - Support updating uv.lock dependabot/dependabot-core#10478
1 parent 852c069 commit 850e76d

File tree

8 files changed

+402
-536
lines changed

8 files changed

+402
-536
lines changed

.devcontainer/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye
2+
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/

.devcontainer/devcontainer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"name": "AoC-Python",
3-
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
46
"features": {
5-
"ghcr.io/devcontainers-contrib/features/mypy:2": {},
6-
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
77
"ghcr.io/devcontainers-contrib/features/shfmt:1.0.0": {},
88
"ghcr.io/lukewiwa/features/shellcheck:0": {}
99
},
10+
"containerEnv": {
11+
"UV_CACHE_DIR": "${containerWorkspaceFolder}/.uv/cache",
12+
"UV_TOOL_DIR": "${containerWorkspaceFolder}/.uv/tools"
13+
},
1014
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
1115
"portsAttributes": {
1216
"8080": {
@@ -20,6 +24,7 @@
2024
"charliermarsh.ruff",
2125
"editorconfig.editorconfig",
2226
"github.vscode-github-actions",
27+
"ms-azuretools.vscode-docker",
2328
"ms-python.mypy-type-checker"
2429
]
2530
}

.devcontainer/post-install.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
set -ex
44

5-
WORKSPACE_DIR=$(pwd)
5+
# Install python tools to be available outside venv
6+
uv tool install poethepoet
67

7-
# Change some Poetry settings to make it more friendly in a container
8-
poetry config cache-dir ${WORKSPACE_DIR}/.poetry_cache
9-
poetry config virtualenvs.in-project true
10-
11-
# Now install all dependencies, including dev dependencies
12-
poetry install --with=dev
8+
# Synchronize venv and dependencies
9+
uv sync
1310

1411
echo "Done!"

.github/workflows/main.yml

+20-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,28 @@ on:
1616
jobs:
1717
build:
1818
runs-on: ubuntu-latest
19+
env:
20+
UV_CACHE_DIR: /tmp/.uv-cache
1921
steps:
2022
- uses: actions/checkout@v4
21-
- name: Install poetry
22-
run: pipx install poetry
23+
- name: Set up uv
24+
# Install latest uv version using the installer
25+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
2326
- uses: actions/setup-python@v5
27+
id: setup_python
2428
with:
2529
python-version: '3.12'
26-
cache: 'poetry'
27-
- run: poetry install
28-
- run: poetry run poe validate
30+
- name: Restore uv cache
31+
uses: actions/cache@v4
32+
with:
33+
path: /tmp/.uv-cache
34+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
35+
restore-keys: |
36+
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
37+
uv-${{ runner.os }}
38+
- name: Install dependencies
39+
run: uv sync
40+
- name: Run verifications
41+
run: uvx --from poethepoet poe validate
42+
- name: Minimize uv cache
43+
run: uv cache prune --ci

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ venv.bak/
144144
.dmypy.json
145145
dmypy.json
146146

147+
# uv
148+
.uv/
149+
147150
# Pyre type checker
148151
.pyre/
149152

poetry.lock

-494
This file was deleted.

pyproject.toml

+23-27
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
[tool.poetry]
1+
[project]
22
name = "adventofcode"
33
version = "0.1.0"
44
description = ""
5-
authors = ["Niko Böckerman <[email protected]>"]
65
readme = "README.md"
7-
8-
[project]
9-
name = "adventofcode"
106
requires-python = ">=3.12"
7+
dependencies = [
8+
"typer>=0.12.4",
9+
"joblib>=1.4.2",
10+
]
11+
12+
[project.scripts]
13+
adventofcode = "adventofcode.main:app"
1114

1215
[tool.poe.tasks]
1316
mypy = "mypy ."
@@ -25,31 +28,24 @@ runall = "adventofcode"
2528
validate = ["lint", "test", "runall"]
2629

2730

28-
[tool.poetry.dependencies]
29-
python = "^3.12"
30-
typer = "^0.12.4"
31-
joblib = "^1.4.2"
32-
33-
[tool.poetry.group.dev.dependencies]
34-
mypy = "^1.11.1"
35-
pytest = "^8.3.2"
36-
ruff = "^0.6.1"
37-
poethepoet = "^0.27.0"
38-
snakeviz = "^2.2.0"
39-
tuna = "^0.5.11"
40-
pyinstrument = "^4.7.2"
41-
pyright = "^1.1.376"
42-
joblib-stubs = "^1.4.2.3.20240619"
43-
44-
[tool.poetry.scripts]
45-
adventofcode = "adventofcode.main:app"
31+
[tool.uv]
32+
dev-dependencies = [
33+
"ruff>=0.6.2",
34+
"pyright>=1.1.377",
35+
"joblib-stubs>=1.4.2.3.20240619",
36+
"mypy>=1.11.1",
37+
"pytest>=8.3.2",
38+
"snakeviz>=2.2.0",
39+
"tuna>=0.5.11",
40+
"pyinstrument>=4.7.2",
41+
]
4642

4743
[tool.pyright]
48-
pythonVersion = "3.12"
44+
#pythonVersion = "3.12"
4945
typeCheckingMode = "strict"
5046

5147
[tool.mypy]
52-
python_version = "3.12"
48+
#python_version = "3.12"
5349
strict_optional = true
5450
enable_incomplete_feature = ["NewGenericSyntax"]
5551

@@ -115,5 +111,5 @@ ignore = [
115111

116112

117113
[build-system]
118-
requires = ["poetry-core"]
119-
build-backend = "poetry.core.masonry.api"
114+
requires = ["hatchling"]
115+
build-backend = "hatchling.build"

uv.lock

+341
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)