Skip to content

Commit

Permalink
WIP: Switch poetry to uv
Browse files Browse the repository at this point in the history
DEPS:
- Support updating uv.lock
  dependabot/dependabot-core issue 10478
  • Loading branch information
nikobockerman committed Aug 22, 2024
1 parent 852c069 commit 48e42a2
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 536 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
11 changes: 8 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "AoC-Python",
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers-contrib/features/mypy:2": {},
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
"ghcr.io/devcontainers-contrib/features/shfmt:1.0.0": {},
"ghcr.io/lukewiwa/features/shellcheck:0": {}
},
"containerEnv": {
"UV_CACHE_DIR": "${containerWorkspaceFolder}/.uv/cache",
"UV_TOOL_DIR": "${containerWorkspaceFolder}/.uv/tools"
},
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
"portsAttributes": {
"8080": {
Expand All @@ -20,6 +24,7 @@
"charliermarsh.ruff",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"ms-azuretools.vscode-docker",
"ms-python.mypy-type-checker"
]
}
Expand Down
11 changes: 4 additions & 7 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

set -ex

WORKSPACE_DIR=$(pwd)
# Install python tools to be available outside venv
uv tool install poethepoet

# Change some Poetry settings to make it more friendly in a container
poetry config cache-dir ${WORKSPACE_DIR}/.poetry_cache
poetry config virtualenvs.in-project true

# Now install all dependencies, including dev dependencies
poetry install --with=dev
# Synchronize venv and dependencies
uv sync

echo "Done!"
25 changes: 20 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
UV_CACHE_DIR: /tmp/.uv-cache
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up uv
# Install latest uv version using the installer
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: actions/setup-python@v5
id: setup_python
with:
python-version: '3.12'
cache: 'poetry'
- run: poetry install
- run: poetry run poe validate
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: uv sync
- name: Run verifications
run: uvx --from poethepoet poe validate
- name: Minimize uv cache
run: uv cache prune --ci
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ venv.bak/
.dmypy.json
dmypy.json

# uv
.uv/

# Pyre type checker
.pyre/

Expand Down
494 changes: 0 additions & 494 deletions poetry.lock

This file was deleted.

50 changes: 23 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[tool.poetry]
[project]
name = "adventofcode"
version = "0.1.0"
description = ""
authors = ["Niko Böckerman <[email protected]>"]
readme = "README.md"

[project]
name = "adventofcode"
requires-python = ">=3.12"
dependencies = [
"typer>=0.12.4",
"joblib>=1.4.2",
]

[project.scripts]
adventofcode = "adventofcode.main:app"

[tool.poe.tasks]
mypy = "mypy ."
Expand All @@ -25,31 +28,24 @@ runall = "adventofcode"
validate = ["lint", "test", "runall"]


[tool.poetry.dependencies]
python = "^3.12"
typer = "^0.12.4"
joblib = "^1.4.2"

[tool.poetry.group.dev.dependencies]
mypy = "^1.11.1"
pytest = "^8.3.2"
ruff = "^0.6.1"
poethepoet = "^0.27.0"
snakeviz = "^2.2.0"
tuna = "^0.5.11"
pyinstrument = "^4.7.2"
pyright = "^1.1.376"
joblib-stubs = "^1.4.2.3.20240619"

[tool.poetry.scripts]
adventofcode = "adventofcode.main:app"
[tool.uv]
dev-dependencies = [
"ruff>=0.6.2",
"pyright>=1.1.377",
"joblib-stubs>=1.4.2.3.20240619",
"mypy>=1.11.1",
"pytest>=8.3.2",
"snakeviz>=2.2.0",
"tuna>=0.5.11",
"pyinstrument>=4.7.2",
]

[tool.pyright]
pythonVersion = "3.12"
#pythonVersion = "3.12"
typeCheckingMode = "strict"

[tool.mypy]
python_version = "3.12"
#python_version = "3.12"
strict_optional = true
enable_incomplete_feature = ["NewGenericSyntax"]

Expand Down Expand Up @@ -115,5 +111,5 @@ ignore = [


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
341 changes: 341 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 48e42a2

Please sign in to comment.