Skip to content

Commit

Permalink
build: migrate from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabbo16 committed Feb 6, 2025
1 parent e660dcf commit a0de767
Show file tree
Hide file tree
Showing 8 changed files with 615 additions and 1,025 deletions.
44 changes: 21 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@ name: Publish to PyPI
on:
release:
types: [published]

jobs:
pypi_release:
name: Builds Using Poetry and Publishes to PyPI
name: Builds Using UV and Publishes to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Poetry
uses: snok/install-poetry@v1
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Configure Poetry
run: poetry config pypi-token.pypi "${{ secrets.PYPI_API_TOKEN }}"
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Build the project
run: uv build
- name: Publish package
run: poetry publish --build
run: uv publish
- name: Minimize uv cache
run: uv cache prune --ci
55 changes: 16 additions & 39 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,31 @@
name: tests

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
tests:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: 3.12
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# run test suite and output coverage file
#----------------------------------------------
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Test with pytest
run: poetry run pytest
run: uv run pytest
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
fail_fast: true
repos:
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.4
hooks:
- id: system
name: Black
entry: poetry run black .
pass_filenames: false
language: system
- repo: local
hooks:
- id: system
name: Isort
entry: poetry run isort .
pass_filenames: false
language: system
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,3 @@ epub-image-optimizer --input-dir <folder> --max-image-resolution 1680 1264 --tin
```

Note: This will optimize all epubs inside `input-dir` folder, used my Kobo Libra H2O screen size as example.

## Development

[Poetry](https://github.com/python-poetry/poetry) is used for managing packages, dependencies and building the project.

Poetry can be installed by following the [instructions](https://github.com/python-poetry/poetry). Afterwards you can use `poetry install` within the project folder to install all dependencies.
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
poetry = "latest"
python = "3.12"
uv = "latest"
Loading

0 comments on commit a0de767

Please sign in to comment.