Migrate project to use uv

This commit is contained in:
Sebastian Goscik
2025-04-09 00:00:44 +01:00
parent e11828bd59
commit 855607fa29
7 changed files with 1782 additions and 2333 deletions

View File

@@ -1,90 +1,88 @@
# This is a basic workflow to help you get started with Actions
name: Test and Build
name: dev workflow
# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the dev branch
push:
branches: [ dev ]
branches-ignore:
- main
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test"
test:
# The type of runner that the job will run on
strategy:
matrix:
python-versions: [3.9]
os: [ubuntu-18.04, macos-latest, windows-latest]
python-versions: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install poetry tox tox-gh-actions
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: test with tox
run:
tox
- name: Install dev dependencies
run: |
uv sync --dev
- name: list files
run: ls -l .
- name: Run pre-commit
run: uv run pre-commit run --all-files
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
files: coverage.xml
- name: Run pytest
run: uv run pytest
- name: Build
run: uv build
dev_container:
name: Create dev container
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request'
# Steps represent a sequence of tasks that will be executed as part of the job
name: Create dev container
needs: test
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10
python-version: '3.12'
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install poetry tox tox-gh-actions
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build wheels and source tarball
run: >-
poetry build
- name: Build
run: uv build
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to container registry
uses: docker/login-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push dev
uses: docker/build-push-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64

View File

@@ -1,6 +1,6 @@
# Publish package on main branch if it's tagged with 'v*'
name: release & publish workflow
name: Release & Publish Workflow
on:
push:
@@ -11,16 +11,17 @@ on:
jobs:
release:
name: Create Release
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
echo "current_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4
- name: Get Changelog Entry
id: changelog_reader
@@ -29,56 +30,57 @@ jobs:
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- uses: actions/setup-python@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install poetry
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build wheels and source tarball
run: >-
poetry build
run: uv build
- name: show temporary files
run: >-
ls -lR
- name: Show build artifacts
run: ls -lR dist/
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
- name: Log in to container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push dev
uses: docker/build-push-action@v2
- name: Build and push container
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.tag_name.outputs.current_version }}, ghcr.io/${{ github.repository }}:latest
tags: |
ghcr.io/${{ github.repository }}:${{ steps.tag_name.outputs.current_version }}
ghcr.io/${{ github.repository }}:latest
- name: create github release
- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog_reader.outputs.changes }}
files: dist/*.whl
files: dist/*
draft: false
prerelease: false
- name: publish to PyPI
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__

View File

@@ -55,12 +55,11 @@ Ready to contribute? Here's how to set up `unifi-protect-backup` for local devel
$ git clone git@github.com:your_name_here/unifi-protect-backup.git
```
3. Ensure [poetry](https://python-poetry.org/docs/) is installed.
4. Install dependencies and start your virtualenv:
3. Ensure [uv](https://docs.astral.sh/uv/) is installed.
4. Create virtual environment and install dependencies:
```
$ poetry install --with dev,test
$ poetry shell
$ uv install --dev
```
5. Create a branch for local development:
@@ -75,21 +74,21 @@ Ready to contribute? Here's how to set up `unifi-protect-backup` for local devel
be inside the `poetry shell` virtualenv or run it via poetry:
```
$ poetry run unifi-protect-backup {args}
$ uv run unifi-protect-backup {args}
```
7. Install pre-commit git hooks to ensure all code commit to the repository
is formatted correctly and meets coding standards:
```
$ poetry run pre-commit install
$ uv run pre-commit install
```
8. When you're done making changes, check that your changes pass the
tests:
```
$ poetry run pytest
$ uv run pytest
```
8. Commit your changes and push your branch to GitHub:
@@ -117,7 +116,7 @@ Before you submit a pull request, check that it meets these guidelines:
## Tips
```
$ poetry run pytest tests/test_unifi_protect_backup.py
$ uv run pytest tests/test_unifi_protect_backup.py
```
To run a subset of tests.
@@ -130,7 +129,7 @@ Make sure all your changes are committed (including an entry in CHANGELOG.md).
Then run:
```
$ poetry run bump2version patch # possible: major / minor / patch
$ uv run bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags
```

View File

@@ -28,5 +28,5 @@ clean:
rm -rf coverage.xml .coverage
docker:
poetry build
uv build
docker buildx build . --platform $(container_arches) -t $(container_name) --push

2195
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +1,61 @@
[tool]
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "unifi_protect_backup"
version = "0.12.0"
homepage = "https://github.com/ep1cman/unifi-protect-backup"
description = "Python tool to backup unifi event clips in realtime."
authors = ["sebastian.goscik <sebastian@goscik.com>"]
readme = "README.md"
license = "MIT"
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
license = {text = "MIT"}
authors = [
{name = "sebastian.goscik", email = "sebastian@goscik.com"}
]
packages = [
{ include = "unifi_protect_backup" },
{ include = "tests", format = "sdist" },
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
]
requires-python = ">=3.10.0,<4.0"
dependencies = [
"click==8.0.1",
"aiorun>=2023.7.2",
"aiosqlite>=0.17.0",
"python-dateutil>=2.8.2",
"apprise>=1.5.0",
"expiring-dict>=1.1.0",
"async-lru>=2.0.4",
"aiolimiter>=1.1.0",
"uiprotect>=6.3.1"
]
[tool.poetry.dependencies]
python = ">=3.10.0,<4.0"
click = "8.0.1"
aiorun = "^2023.7.2"
aiosqlite = "^0.17.0"
python-dateutil = "^2.8.2"
apprise = "^1.5.0"
expiring-dict = "^1.1.0"
async-lru = "^2.0.4"
aiolimiter = "^1.1.0"
uiprotect = "^6.3.1"
[project.urls]
Homepage = "https://github.com/ep1cman/unifi-protect-backup"
[tool.poetry.group.dev]
optional = true
[project.scripts]
unifi-protect-backup = "unifi_protect_backup.cli:main"
[tool.poetry.group.dev.dependencies]
mypy = "^1.11.1"
types-pytz = "^2021.3.5"
types-cryptography = "^3.3.18"
types-python-dateutil = "^2.8.19.10"
bump2version = "^1.0.1"
pre-commit = "^2.12.0"
ruff = "^0.5.7"
types-aiofiles = "^24.1.0.20241221"
[dependency-groups]
dev = [
"mypy>=1.11.1",
"types-pytz>=2021.3.5",
"types-cryptography>=3.3.18",
"types-python-dateutil>=2.8.19.10",
"bump2version>=1.0.1",
"pre-commit>=2.12.0",
"ruff>=0.5.7",
"types-aiofiles>=24.1.0.20241221",
"pytest>=6.2.4",
]
[tool.poetry.group.test]
optional = true
[tool.hatch.build.targets.wheel]
packages = ["unifi_protect_backup"]
[tool.poetry.group.test.dependencies]
pytest = "^6.2.4"
pytest-cov = "^2.12.0"
tox = "^3.20.1"
tox-asdf = "^0.1.0"
[tool.poetry.scripts]
unifi-protect-backup = 'unifi_protect_backup.cli:main'
[tool.hatch.build.targets.sdist]
include = ["unifi_protect_backup", "tests"]
[tool.ruff]
line-length = 120
@@ -66,11 +66,10 @@ target-version = "py310"
[tool.ruff.format]
[tool.mypy]
allow_redefinition=true
allow_redefinition = true
exclude = [
'unifi_protect_backup/uiprotect_patch.py'
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
default-groups = []

1646
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff