Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch poetry to uv #24

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,13 +1,17 @@
{
"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": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"containerEnv": {
"UV_CACHE_DIR": "${containerWorkspaceFolder}/.uv/cache",
"UV_TOOL_DIR": "${containerWorkspaceFolder}/.uv/tools"
},
"postCreateCommand": "bash ./.devcontainer/post-install.sh",
"portsAttributes": {
"8080": {
Expand All @@ -21,6 +25,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 --sync
# Synchronize venv and dependencies
uv sync

echo "Done!"
32 changes: 22 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@ on:
workflow_dispatch:
schedule:
# Run every Monday at 00:30 UTC
- cron: '30 0 * * 1'
- cron: "30 0 * * 1"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'poetry'
- run: poetry install
- run: poetry run poe validate
- uses: actions/checkout@v4

- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
version: "^0.4.20"
enable-cache: true
- run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"

- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: python --version

- name: Install project
run: uv sync --all-extras --dev

- name: Run validations
run: uvx --from poethepoet poe validate
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
587 changes: 0 additions & 587 deletions poetry.lock

This file was deleted.

52 changes: 24 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[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 = [
"attrs >=24.2.0,<25",
"typer >=0.12.5,<0.13",
"joblib >=1.4.2,<2",
]

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

[tool.poe.tasks]
mypy = "mypy ."
Expand All @@ -34,32 +38,24 @@ fi
shellcheck $(git ls-files | grep '\\..*sh')
"""

[tool.poetry.dependencies]
python = "^3.12"
typer = "^0.12.5"
joblib = "^1.4.2"
attrs = "^24.2.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.11.2"
pytest = "^8.3.3"
ruff = "^0.6.9"
poethepoet = "^0.29.0"
snakeviz = "^2.2.0"
tuna = "^0.5.11"
pyinstrument = "^4.7.3"
pyright = {extras = ["nodejs"], version = "^1.1.383"}
joblib-stubs = "^1.4.2.5.20240918"

[tool.poetry.scripts]
adventofcode = "adventofcode.main:app"
[tool.uv]
dev-dependencies = [
"ruff >=0.6.9,<0.7",
"pyright[nodejs] >=1.1.383,<2",
"joblib-stubs >=1.4.2.5.20240918,<2",
"mypy >=1.11.2,<2",
"pytest >=8.3.3,<9",
"snakeviz >=2.2.0,<3",
"tuna >=0.5.11,<0.6",
"pyinstrument >=4.7.3,<5",
]

[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 @@ -126,5 +122,5 @@ ignore = [


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

Large diffs are not rendered by default.