Skip to content

Commit

Permalink
build: poetry -> uv
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 15, 2024
1 parent 3dad21b commit 7714ad3
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 298 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ jobs:
uses: yezz123/setup-uv@v4
- name: Install dependencies
run: |
pip install --upgrade pip
pip install poetry
poetry install
uv sync
- name: Test with pytest (PyQt6)
# combine test coverage with --cov-append?
uses: coactions/setup-xvfb@v1
timeout-minutes: 5
with:
run: |
poetry install -E pyqt6 -E addons
poetry run pytest
uv sync --extra pyqt6 --extra addons
uv run pytest
- name: Test with pytest (PySide6)
uses: coactions/setup-xvfb@v1
# if: runner.os == 'Linux'
timeout-minutes: 5
with:
run: |
poetry install -E pyside6 -E addons
poetry run pytest --doctest-modules --junitxml=junit/test-results.xml --cov=prettyqt --cov-report=xml --cov-report=html
uv sync --extra pyside6 --extra addons
uv run pytest --doctest-modules --junitxml=junit/test-results.xml --cov=prettyqt --cov-report=xml --cov-report=html
- name: Upload coverage to Codecov
if: runner.os == 'Windows' && matrix.python-version == '3.11'
Expand All @@ -63,8 +61,8 @@ jobs:
timeout-minutes: 10
with:
run: |
poetry install -E pyside6 -E addons
poetry run mkdocs build
uv sync --extra pyside6 --extra addons
uv run mkdocs build
# - name: Build and publish
# if: startsWith(github.ref, 'refs/tags/v') && matrix.python-version == '3.11' && runner.os == 'Linux'
# run: |
Expand All @@ -91,22 +89,23 @@ jobs:
python-version: "3.11"

- name: Install packages

# if: runner.os == 'Linux'
run: |
pip install --upgrade pip
pip install poetry
poetry install -E pyside6 -E addons
uv sync --extra pyside6 --extra addons
- name: Build documentation
uses: coactions/setup-xvfb@v1
timeout-minutes: 10
with:
run: |
poetry run mkdocs build
- name: Build and publish
uv run mkdocs build
- name: Build
run: |
uv build
- name: Publish on PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_SECRET }}
poetry publish --build
uv publish
# - name: Deploy docs
# # if: github.event_name == 'push'
# uses: mhausenblas/mkdocs-deploy-gh-pages@master
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
hooks:
- id: pytest-check
name: pytest-check
entry: poetry run pytest
entry: uv run pytest
language: system
stages: [pre-push]
types: [python]
Expand Down
28 changes: 14 additions & 14 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
from duty import duty


ENV_PREFIX = "poetry run "


@duty(capture=False)
def build(ctx, *args: str):
"""Build a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes build{args_str}")
ctx.run(f"uv run mknodes build{args_str}")


@duty(capture=False)
def serve(ctx, *args: str):
"""Serve a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes serve{args_str}")
ctx.run(f"uv run mknodes serve{args_str}")


@duty(capture=False)
Expand All @@ -35,7 +32,7 @@ def test_pyside6(ctx, *args: str):
os.environ["QT_API"] = "pyside6"
args = ("--cov-report=xml", *args)
args_str = " " + " ".join(args)
ctx.run(f"{ENV_PREFIX}pytest{args_str}")
ctx.run(f"uv run pytest{args_str}")


@duty(capture=False)
Expand All @@ -44,7 +41,7 @@ def test_pyqt6(ctx, *args: str):
os.environ["QT_API"] = "pyqt6"
args = ("--cov-report=xml", *args)
args_str = " " + " ".join(args)
ctx.run(f"{ENV_PREFIX}pytest{args_str}")
ctx.run(f"uv run pytest{args_str}")


@duty(capture=False)
Expand All @@ -56,27 +53,30 @@ def clean(ctx):
@duty(capture=False)
def update(ctx, *args: str):
"""Update all environment packages using pip directly."""
ctx.run("poetry update")
ctx.run("poetry install --all-extras")
ctx.run("uv sync --all-extras")


@duty(capture=False)
def lint(ctx):
"""Update all environment packages using pip directly."""
ctx.run(f"{ENV_PREFIX}lint")
"""Lint and fix the code."""
ctx.run("uv run ruff check --fix .")
ctx.run("uv run ruff format .")
ctx.run("uv run mypy prettyqt/")


@duty(capture=False)
def lint_check(ctx):
"""Update all environment packages using pip directly."""
ctx.run(f"{ENV_PREFIX}lint-check")
"""Lint the code."""
ctx.run("uv run ruff check .")
ctx.run("uv run ruff format --check .")
ctx.run("uv run mypy prettyqt/")


@duty(capture=False)
def profile(ctx, *args: str):
"""Run generating the docs using pyinstrument."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}pyinstrument mknodes/manual/root.py{args_str}")
ctx.run(f"uv run pyinstrument mknodes/manual/root.py{args_str}")


@duty(capture=False)
Expand Down
Loading

0 comments on commit 7714ad3

Please sign in to comment.