mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Migrate from poetry to uv for dependency and package management (#986)
This commit is contained in:
40
.github/actions/setup/action.yaml
vendored
40
.github/actions/setup/action.yaml
vendored
@@ -1,16 +1,18 @@
|
||||
---
|
||||
name: Setup Environment
|
||||
description: Install requested pipx dependencies, configure the system python, and install poetry and the package dependencies
|
||||
description: Install requested pipx dependencies, configure the system python, and install uv and the package dependencies
|
||||
|
||||
inputs:
|
||||
poetry-install-options:
|
||||
uv-install-options:
|
||||
default: ""
|
||||
poetry-version:
|
||||
default: 1.8.2
|
||||
uv-version:
|
||||
default: 0.4.5
|
||||
python-version:
|
||||
required: true
|
||||
cache-pre-commit:
|
||||
default: false
|
||||
cache-version:
|
||||
default: "v0.1"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
@@ -25,7 +27,7 @@ runs:
|
||||
id: pipx-env-setup
|
||||
# pipx default home and bin dir are not writable by the cache action
|
||||
# so override them here and add the bin dir to PATH for later steps.
|
||||
# This also ensures the pipx cache only contains poetry
|
||||
# This also ensures the pipx cache only contains uv
|
||||
run: |
|
||||
SEP="${{ !startsWith(runner.os, 'windows') && '/' || '\\' }}"
|
||||
PIPX_CACHE="${{ github.workspace }}${SEP}pipx_cache"
|
||||
@@ -42,43 +44,43 @@ runs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.pipx-env-setup.outputs.pipx-cache-path }}
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-pipx-${{ steps.pipx-env-setup.outputs.pipx-version }}-poetry-${{ inputs.poetry-version }}
|
||||
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-${{ runner.arch }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-pipx-${{ steps.pipx-env-setup.outputs.pipx-version }}-uv-${{ inputs.uv-version }}
|
||||
|
||||
- name: Install poetry
|
||||
- name: Install uv
|
||||
if: steps.pipx-cache.outputs.cache-hit != 'true'
|
||||
id: install-poetry
|
||||
id: install-uv
|
||||
shell: bash
|
||||
run: |-
|
||||
pipx install poetry==${{ inputs.poetry-version }} --python "${{ steps.setup-python.outputs.python-path }}"
|
||||
pipx install uv==${{ inputs.uv-version }} --python "${{ steps.setup-python.outputs.python-path }}"
|
||||
|
||||
- name: Read poetry cache location
|
||||
id: poetry-cache-location
|
||||
- name: Read uv cache location
|
||||
id: uv-cache-location
|
||||
shell: bash
|
||||
run: |-
|
||||
echo "poetry-venv-location=$(poetry config virtualenvs.path)" >> $GITHUB_OUTPUT
|
||||
echo "uv-cache-location=$(uv cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v4
|
||||
name: Poetry cache
|
||||
name: uv cache
|
||||
with:
|
||||
path: |
|
||||
${{ steps.poetry-cache-location.outputs.poetry-venv-location }}
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}-options-${{ inputs.poetry-install-options }}
|
||||
${{ steps.uv-cache-location.outputs.uv-cache-location }}
|
||||
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-${{ runner.arch }}-python-${{ steps.setup-python.outputs.python-version }}-uv-${{ inputs.uv-version }}-${{ hashFiles('uv.lock') }}-options-${{ inputs.uv-install-options }}
|
||||
|
||||
- name: "Poetry install"
|
||||
- name: "uv install"
|
||||
shell: bash
|
||||
run: |
|
||||
poetry install ${{ inputs.poetry-install-options }}
|
||||
uv sync --python "${{ steps.setup-python.outputs.python-path }}" ${{ inputs.uv-install-options }}
|
||||
|
||||
- name: Read pre-commit version
|
||||
if: inputs.cache-pre-commit == 'true'
|
||||
id: pre-commit-version
|
||||
shell: bash
|
||||
run: >-
|
||||
echo "pre-commit-version=$(poetry run pre-commit -V | awk '{print $2}')" >> $GITHUB_OUTPUT
|
||||
echo "pre-commit-version=$(uv run pre-commit -- -V | awk '{print $2}')" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v4
|
||||
if: inputs.cache-pre-commit == 'true'
|
||||
name: Pre-commit cache
|
||||
with:
|
||||
path: ~/.cache/pre-commit/
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-pre-commit-${{ steps.pre-commit-version.outputs.pre-commit-version }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
key: cache-${{ inputs.cache-version }}-${{ runner.os }}-${{ runner.arch }}-pre-commit-${{ steps.pre-commit-version.outputs.pre-commit-version }}-python-${{ inputs.python-version }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
|
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
workflow_dispatch: # to allow manual re-runs
|
||||
|
||||
env:
|
||||
POETRY_VERSION: 1.8.2
|
||||
UV_VERSION: 0.4.5
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
@@ -26,32 +26,33 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache-pre-commit: true
|
||||
poetry-version: ${{ env.POETRY_VERSION }}
|
||||
poetry-install-options: "--all-extras"
|
||||
uv-version: ${{ env.UV_VERSION }}
|
||||
uv-install-options: "--all-extras"
|
||||
- name: "Check supported device md files are up to date"
|
||||
run: |
|
||||
poetry run pre-commit run generate-supported --all-files
|
||||
uv run pre-commit run generate-supported --all-files
|
||||
- name: "Linting and code formating (ruff)"
|
||||
run: |
|
||||
poetry run pre-commit run ruff --all-files
|
||||
uv run pre-commit run ruff --all-files
|
||||
- name: "Typing checks (mypy)"
|
||||
run: |
|
||||
poetry run pre-commit run mypy --all-files
|
||||
source .venv/bin/activate
|
||||
pre-commit run mypy --all-files
|
||||
- name: "Run trailing-whitespace"
|
||||
run: |
|
||||
poetry run pre-commit run trailing-whitespace --all-files
|
||||
uv run pre-commit run trailing-whitespace --all-files
|
||||
- name: "Run end-of-file-fixer"
|
||||
run: |
|
||||
poetry run pre-commit run end-of-file-fixer --all-files
|
||||
uv run pre-commit run end-of-file-fixer --all-files
|
||||
- name: "Run check-docstring-first"
|
||||
run: |
|
||||
poetry run pre-commit run check-docstring-first --all-files
|
||||
uv run pre-commit run check-docstring-first --all-files
|
||||
- name: "Run debug-statements"
|
||||
run: |
|
||||
poetry run pre-commit run debug-statements --all-files
|
||||
uv run pre-commit run debug-statements --all-files
|
||||
- name: "Run check-ast"
|
||||
run: |
|
||||
poetry run pre-commit run check-ast --all-files
|
||||
uv run pre-commit run check-ast --all-files
|
||||
|
||||
|
||||
tests:
|
||||
@@ -89,16 +90,16 @@ jobs:
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
poetry-version: ${{ env.POETRY_VERSION }}
|
||||
poetry-install-options: ${{ matrix.extras == true && '--all-extras' || '' }}
|
||||
uv-version: ${{ env.UV_VERSION }}
|
||||
uv-install-options: ${{ matrix.extras == true && '--all-extras' || '' }}
|
||||
- name: "Run tests (no coverage)"
|
||||
if: ${{ startsWith(matrix.python-version, 'pypy') }}
|
||||
run: |
|
||||
poetry run pytest
|
||||
uv run pytest
|
||||
- name: "Run tests (with coverage)"
|
||||
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
||||
run: |
|
||||
poetry run pytest --cov kasa --cov-report xml
|
||||
uv run pytest --cov kasa --cov-report xml
|
||||
- name: "Upload coverage to Codecov"
|
||||
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
|
||||
uses: "codecov/codecov-action@v4"
|
||||
|
20
.github/workflows/publish.yml
vendored
20
.github/workflows/publish.yml
vendored
@@ -3,6 +3,9 @@ on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
env:
|
||||
UV_VERSION: 0.4.5
|
||||
|
||||
jobs:
|
||||
build-n-publish:
|
||||
name: Build release packages
|
||||
@@ -17,19 +20,10 @@ jobs:
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install pypa/build
|
||||
run: >-
|
||||
python -m
|
||||
pip install
|
||||
build
|
||||
--user
|
||||
- name: Install uv
|
||||
run: |-
|
||||
pipx install uv==${{ env.UV_VERSION }} --python "${{ steps.setup-python.outputs.python-path }}"
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: >-
|
||||
python -m
|
||||
build
|
||||
--sdist
|
||||
--wheel
|
||||
--outdir dist/
|
||||
.
|
||||
run: uv build
|
||||
- name: Publish release on pypi
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
|
Reference in New Issue
Block a user