Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use uv instead of poetry #608

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.11'
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
enable-cache: true

- name: "Set up Python"
uses: actions/setup-python@v5
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
python-version-file: ".python-version"

- name: Install Dependencies
- name: Install the project
run: |
poetry install
uv sync --all-extras --dev

- name: Invoke sphinx-build
run: |
poetry run make -C docs SPHINXOPTS="-W" html
uv run make -C docs SPHINXOPTS="-W" html

- name: Archive webpage
uses: actions/upload-artifact@v4
with:
Expand All @@ -51,12 +55,6 @@ jobs:
if: github.ref == 'refs/heads/master'

steps:
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Download all workflow run artifacts
uses: actions/download-artifact@v4

Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/linters-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
enable-cache: true

- name: Install Dependencies
- name: Set up Python ${{ matrix.python-version }}
run: |
poetry install
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}

- name: Install the project
run: |
uv sync --all-extras --dev

- name: Run mypy
run: |
poetry run make lint-win32
uv run make lint-win32
34 changes: 20 additions & 14 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
pull_request:
paths:
- 'pyproject.toml'
- 'poetry.lock'
- 'uv.lock'
- '.github/**'
- 'src/**'
- 'tests/**'
Expand All @@ -29,27 +29,33 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: |
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}

- name: Install Dependencies
- name: Install the project
run: |
poetry install
uv sync --all-extras --dev

- name: Run ruff
run: |
poetry run ruff check src tests
uv run ruff check src tests

- name: Run mypy
run: |
poetry run mypy src tests
uv run mypy src tests

- name: Run ruff format
run: |
poetry run ruff format --check src tests
uv run ruff format --check src tests

- name: Run reuse lint
run: |
poetry run reuse lint
uv run reuse lint
19 changes: 10 additions & 9 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.11'
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4
enable-cache: true

- uses: actions/setup-python@v5
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
python-version-file: ".python-version"

- name: Install Dependencies
- name: Install the project
run: |
poetry install
uv sync --all-extras

- name: Build package
run: |
poetry build
uv build

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
43 changes: 28 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v9
- uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
enable-cache: true

- name: Install Dependencies
- name: Set up Python ${{ matrix.python-version }}
run: |
poetry install
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}

- name: Install the project
run: |
uv sync --all-extras --dev

- name: Run pytest
run: |
poetry run make pytest
uv run make pytest

bats:
strategy:
Expand All @@ -52,14 +55,24 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }}
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: |
uv python install ${{ matrix.python-version }}

- name: Install Dependencies
run: |
apt-get update -y && apt-get install -y bats python3 python3-poetry jq zstd
poetry install

- name: Install the project
run: |
uv sync --all-extras --dev

- name: Run bats
run: |
poetry run make bats
uv run make bats
39 changes: 0 additions & 39 deletions .github/workflows/upload-artifacts.yml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
File renamed without changes.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ FROM debian:stable

LABEL org.opencontainers.image.authors="stefan.tatschner@aisec.fraunhofer.de"

RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y python3 python3-poetry
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y pipx

WORKDIR /app/gallia
COPY . .
RUN ["poetry", "install"]

ENTRYPOINT [ "poetry", "run", "gallia" ]
ENV PATH="/root/.local/bin:$PATH"
RUN ["pipx", "install", "uv"]
RUN ["uv", "sync"]

ENTRYPOINT [ "uv", "run", "gallia" ]
34 changes: 12 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
default:
@echo "available targets:"
@echo ""
@echo " zipapp build a standalone python zipapp"
@echo " fmt run autoformatters"
@echo " lint run linters"
@echo " docs build docs"
Expand All @@ -15,49 +14,40 @@ default:
@echo " bats run bats end to end tests"
@echo " clean delete build artifacts"

.PHONY: zipapp
TEMPDIR = $(shell mktemp -d)
zipapp:
poetry build -f wheel
poetry run python -m pip install --target $(TEMPDIR) gallia dist/*.whl
poetry run python -m zipapp -o gallia.pyz -c -p "/usr/bin/env python3" -m "gallia.cli:main" $(TEMPDIR)
$(RM) -r $(TEMPDIR)

.PHONY: lint
lint:
mypy src tests
ruff check src tests
ruff format --check src tests
uv run mypy src tests
uv run ruff check src tests
uv run ruff format --check src tests
find tests/bats \( -iname "*.bash" -or -iname "*.bats" -or -iname "*.sh" \) | xargs shellcheck
reuse lint
uv run reuse lint

.PHONY: lint-win32
lint-win32:
mypy --platform win32 --exclude "gallia\/log\.py" --exclude "hr" src tests
ruff check src tests
uv run mypy --platform win32 --exclude "gallia\/log\.py" --exclude "hr" src tests
uv run ruff check src tests

.PHONY: fmt
fmt:
ruff check --fix-only src tests/pytest
ruff format src tests/pytest
uv run ruff check --fix-only src tests/pytest
uv run ruff format src tests/pytest
find tests/bats \( -iname "*.bash" -or -iname "*.bats" -or -iname "*.sh" \) | xargs shfmt -w

.PHONY: docs
docs:
$(MAKE) -C docs html
uv run $(MAKE) -C docs html

.PHONY: tests
tests: pytest bats

.PHONY: pytest
pytest:
python -m pytest -v --cov=$(PWD) --cov-report html tests/pytest
uv run python -m pytest -v --cov=$(PWD) --cov-report html tests/pytest

.PHONY: bats
bats:
./tests/bats/run_bats.sh
uv run ./tests/bats/run_bats.sh

.PHONY: clean
clean:
$(RM) gallia.pyz
$(MAKE) -C docs clean
uv run $(MAKE) -C docs clean
8 changes: 0 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,3 @@ All available transports are documented in {doc}`../transports`.
:members:
:show-inheritance:
```

## opennetzteil.netzteil

```{eval-rst}
.. automodule:: opennetzteil.netzteil
:members:
:show-inheritance:
```
6 changes: 2 additions & 4 deletions docs/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ SPDX-License-Identifier: CC0-1.0
Power supplies are mostly used for power cycling the current device under test.
There is no limit in accessing power supplies, e.g. voltage or current settings can be controlled as well.

Own drivers can be included by implementing the {class}`opennetzteil.netzteil.BaseNetzteil` interface[^1].
Own drivers can be included by implementing the {class}`gallia.power_supply.BasePowerSupply` interface.
On the commandline there is the `--power-supply` argument to specify a relevant power supply.
Further, there is `--power-cycle` to automatically power-cycle the device under test.
There is an experimental cli tool `opennetzteil` included in `gallia`.
There is an experimental cli tool `netzteil` included in `gallia`.
This cli tool can be used to control all supported power supplies via the cli.

[^1]: `opennetzteil` is included and shipped with `gallia`.

The argument for `--power-supply` is a URI of the following form:

``` text
Expand Down
Loading