Skip to content
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
6 changes: 4 additions & 2 deletions .github/workflows/test_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ jobs:
python-version: "3.13"
- name: Install tox
run: pip install tox
- name: Run tox
run: tox
- name: Lint
run: tox run -e lint
- name: Unit
run: tox run -e unit
5 changes: 4 additions & 1 deletion .github/workflows/tics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pipx pkgconf libssl-dev build-essential
sudo apt-get install -y pipx pkgconf python3-maturin libssl-dev build-essential

# Client
- name: Install Rust toolchain
Expand All @@ -39,6 +39,9 @@ jobs:
- name: Build (client)
working-directory: client
run: cargo build --all-features
- name: Install (client pybindings)
working-directory: client
run: pip install . --break-system-packages

# Server
- name: Set up uv
Expand Down
4 changes: 4 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ __pycache__/
*.profraw
*.profdata
coverage*
.tox/
.ruff_cache/
.mypy_cache/
.venv/
13 changes: 6 additions & 7 deletions client/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ sudo snap connect hwctl:system-observe
## Use Python Bindings

The `hwlib` library can be used in Python code as well. We're using the
[`pyo3`][pyo3] library to create Python bindings; to build them, you need to
have [`maturin`][maturin] installed on your system. It requires a virtual
environment to be configured to work with it:
[`pyo3`][pyo3] library to create Python bindings and [`maturin`][maturin] to
build the Python library. It requires a virtual environment to be configured to
work with it:

```shell
virtualenv venv
source venv/bin/activate
pip install maturin
maturin develop --features pybindings
python3 -m venv .venv
source .venv/bin/activate
pip install .
```

Now you can use the library in your Python code. The library requires root
Expand Down
6 changes: 6 additions & 0 deletions client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["maturin>=1.9,<2.0"]
build-backend = "maturin"

[tool.maturin]
features = ["pybindings"]
28 changes: 18 additions & 10 deletions client/tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
[tox]
envlist = py
skipsdist = true
env_list = format, lint, unit

[testenv:format]
description = Apply coding standards to code
deps =
ruff
commands =
ruff check --fix
ruff format

[testenv]
[testenv:lint]
description = Check code against coding stle standards
deps =
black
ruff
commands =
ruff check
ruff format --check

[testenv:unit]
description = Run unit tests
deps =
pytest
maturin
commands_pre =
{envbindir}/maturin develop --features pybindings
commands =
{envbindir}/python -m black --check pytests/
{envbindir}/python -m ruff check pytests/
{envbindir}/python -m pytest pytests/
pytest pytests
Loading