Merge pull request #114 from malmeloo/migrate-uv

chore: Migrate from poetry to uv
This commit is contained in:
Mike Almeloo
2025-04-08 13:42:39 +02:00
committed by GitHub
19 changed files with 1841 additions and 2176 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 --all-groups

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
```

View File

@@ -5,10 +5,10 @@ from .accessory import FindMyAccessory
from .keys import KeyPair
__all__ = (
"FindMyAccessory",
"KeyPair",
"errors",
"keys",
"reports",
"scanner",
"errors",
"FindMyAccessory",
"KeyPair",
)

View File

@@ -10,13 +10,16 @@ import logging
import plistlib
from abc import ABC, abstractmethod
from datetime import datetime, timedelta, timezone
from typing import IO, Generator, overload
from typing import IO, TYPE_CHECKING, overload
from typing_extensions import override
from .keys import KeyGenerator, KeyPair, KeyType
from .util import crypto
if TYPE_CHECKING:
from collections.abc import Generator
logging.getLogger(__name__)

View File

@@ -7,13 +7,16 @@ import hashlib
import secrets
from abc import ABC, abstractmethod
from enum import Enum
from typing import Generator, Generic, TypeVar, overload
from typing import TYPE_CHECKING, Generic, TypeVar, overload
from cryptography.hazmat.primitives.asymmetric import ec
from typing_extensions import override
from .util import crypto, parsers
if TYPE_CHECKING:
from collections.abc import Generator
class KeyType(Enum):
"""Enum of possible key types."""

View File

@@ -8,8 +8,8 @@ from .twofactor import SmsSecondFactorMethod, TrustedDeviceSecondFactorMethod
__all__ = (
"AppleAccount",
"AsyncAppleAccount",
"LoginState",
"BaseAnisetteProvider",
"LoginState",
"RemoteAnisetteProvider",
"SmsSecondFactorMethod",
"TrustedDeviceSecondFactorMethod",

View File

@@ -7,7 +7,7 @@ from .scanner import (
)
__all__ = (
"OfflineFindingScanner",
"NearbyOfflineFindingDevice",
"OfflineFindingScanner",
"SeparatedOfflineFindingDevice",
)

View File

@@ -7,7 +7,7 @@ import logging
import time
from abc import ABC, abstractmethod
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any, AsyncGenerator
from typing import TYPE_CHECKING, Any
from bleak import BleakScanner
from typing_extensions import override
@@ -16,6 +16,8 @@ from findmy.accessory import RollingKeyPairSource
from findmy.keys import HasPublicKey
if TYPE_CHECKING:
from collections.abc import AsyncGenerator
from bleak.backends.device import BLEDevice
from bleak.backends.scanner import AdvertisementData

View File

@@ -3,4 +3,4 @@
from .http import HttpResponse, HttpSession
from .parsers import decode_plist
__all__ = ("HttpSession", "HttpResponse", "decode_plist")
__all__ = ("HttpResponse", "HttpSession", "decode_plist")

View File

@@ -1,6 +1,7 @@
"""Utility types."""
from typing import Coroutine, TypeVar, Union
from collections.abc import Coroutine
from typing import TypeVar, Union
T = TypeVar("T")

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 = "."
@@ -46,11 +40,6 @@ venv = ".venv"
typeCheckingMode = "standard"
reportImplicitOverride = true
# examples should be run from their own directory
executionEnvironments = [
{ root = "examples/" }
]
[tool.ruff]
line-length = 100
@@ -64,8 +53,6 @@ select = [
"ALL",
]
ignore = [
"ANN101", # annotations on `self`
"ANN102", # annotations on `cls`
"FIX002", # resolving TODOs
"D203", # one blank line before class docstring
@@ -91,6 +78,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