chore: migrate from poetry to uv

This commit is contained in:
Mike A.
2025-02-27 22:03:45 +01:00
parent bd6cea4b79
commit 329e6d963c
11 changed files with 1822 additions and 2159 deletions

View File

@@ -1,48 +1,25 @@
name: Common Python + Poetry Setup
name: Common Python + UV Setup
inputs:
dependency-groups:
description: 'A comma-separated list of dependency groups to install'
default: 'main'
python-version:
description: 'The Python version to use'
default: '3.10'
description: 'The Python version to install'
required: false
runs:
using: 'composite'
steps:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install poetry
if: ${{ inputs.python-version != '' }}
shell: bash
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
- name: Get cache key
id: cache-key
shell: bash
run: |
key=$(echo "${{ inputs.dependency-groups }}" | sed 's/,/+/')
echo "key=$key" >> "$GITHUB_OUTPUT"
- name: Get full Python version
id: full-python-version
shell: bash
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
- name: Load cached venv
id: cache-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-py${{ steps.full-python-version.outputs.version }}-grp${{ steps.cache-key.outputs.key }}-${{ hashFiles('**/poetry.lock') }}
run: uv python install
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
shell: bash
run: poetry install --with ${{ inputs.dependency-groups }}
run: uv sync --all-extras --dev

View File

@@ -17,14 +17,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: './.github/actions/setup-project'
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
dependency-groups: 'docs'
python-version: ${{ matrix.python-version }}
- name: Build documentation
run: |
cd docs
poetry run make html
uv run make html
- name: Setup Pages
uses: actions/configure-pages@v5

View File

@@ -14,8 +14,6 @@ jobs:
- uses: actions/checkout@v4
- uses: './.github/actions/setup-project'
with:
dependency-groups: 'dev,test'
- uses: pre-commit/action@v3.0.1

View File

@@ -17,19 +17,16 @@ jobs:
- uses: actions/checkout@v4
- uses: './.github/actions/setup-project'
with:
dependency-groups: 'dev'
- name: Prepare README
run: ./scripts/refactor_readme.py README.md
- name: Build package
run: poetry build
run: uv build
- name: Publish package
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish
uv publish --token ${{ secrets.PYPI_API_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v2

View File

@@ -17,14 +17,12 @@ jobs:
- uses: actions/checkout@v4
- uses: './.github/actions/setup-project'
with:
dependency-groups: 'dev'
- id: supported-versions
name: Get supported versions
run: |
set -e
echo "py-versions=$(poetry run ./scripts/supported_py_versions.py)" >> "$GITHUB_OUTPUT"
echo "py-versions=$(uv run ./scripts/supported_py_versions.py)" >> "$GITHUB_OUTPUT"
test:
runs-on: ubuntu-latest
@@ -40,10 +38,9 @@ jobs:
- uses: './.github/actions/setup-project'
with:
python-version: ${{ matrix.py-version }}
dependency-groups: 'test'
- name: Run unit tests
run: poetry run pytest
run: uv run pytest
results:
runs-on: ubuntu-latest

View File

@@ -66,8 +66,8 @@ Before opening a pull request, please ensure that your code adheres to these rul
There are pre-commit hooks included to help you with this, which you can set up as follows:
```shell
pip install poetry
poetry install --with dev # this installs pre-commit into your environment
pip install uv
uv sync # this installs ruff & pre-commit into your environment
pre-commit install
```

2068
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,42 +1,36 @@
[tool.poetry]
[project]
name = "FindMy"
version = "v0.7.6"
description = "Everything you need to work with Apple's Find My network!"
authors = ["Mike Almeloo <git@mikealmel.ooo>"]
readme = "README.md"
packages = [{ include = "findmy" }]
authors = [
{name = "Mike Almeloo", email = "git@mikealmel.ooo"},
]
requires-python = ">=3.9,<3.14"
dependencies = [
"srp>=1.0.21,<2.0.0",
"cryptography>=42.0.0,<45.0.0",
"beautifulsoup4>=4.12.3,<5.0.0",
"aiohttp>=3.9.5,<4.0.0",
"bleak>=0.22.2,<1.0.0",
"typing-extensions>=4.12.2,<5.0.0",
]
[tool.poetry.dependencies]
python = ">=3.9,<3.14"
srp = "^1.0.21"
cryptography = ">=42.0.0,<45.0.0"
beautifulsoup4 = "^4.12.3"
aiohttp = "^3.9.5"
bleak = "^0.22.2"
typing-extensions = "^4.12.2"
[tool.poetry.group.dev]
optional = true
[tool.poetry.group.dev.dependencies]
pre-commit = "^3.8.0"
pyright = "^1.1.391"
ruff = "^0.8.4"
tomli = "^2.0.1"
packaging = "^24.1"
[tool.poetry.group.test]
optional = true
[tool.poetry.group.test.dependencies]
pytest = "^8.3.2"
[tool.poetry.group.docs]
optional = true
[tool.poetry.group.docs.dependencies]
sphinx = "^7.2.6"
sphinx-autoapi = "3.4.0"
[dependency-groups]
dev = [
"pre-commit>=3.8.0,<4.0.0",
"pyright>=1.1.391,<2.0.0",
"ruff>=0.8.4,<1.0.0",
"tomli>=2.0.1,<3.0.0",
"packaging>=24.1,<25.0",
]
test = [
"pytest>=8.3.2,<9.0.0",
]
docs = [
"sphinx>=7.2.6,<8.0.0",
"sphinx-autoapi==3.4.0",
]
[tool.pyright]
venvPath = "."
@@ -91,6 +85,9 @@ ignore = [
"D", # documentation
]
[tool.setuptools]
license-files = []
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import json
from collections.abc import Generator
from itertools import count
from pathlib import Path
from typing import Generator
import tomli
from packaging.specifiers import SpecifierSet
@@ -15,7 +15,7 @@ def get_python_versions() -> Generator[str, None, None]:
with Path("pyproject.toml").open("rb") as f:
pyproject_data = tomli.load(f)
specifier = SpecifierSet(pyproject_data["tool"]["poetry"]["dependencies"]["python"])
specifier = SpecifierSet(pyproject_data["project"]["requires-python"])
below_spec = True
for v_minor in count():

View File

@@ -1,9 +1,12 @@
{ pkgs ? import <nixpkgs> {} }:
let
unstable = import (fetchTarball https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz) { };
in
pkgs.mkShell {
packages = with pkgs; [
python312
poetry
unstable.uv
];
shellHook = ''

1761
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff