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
31 changes: 22 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "Testing package"

on:
pull_request:
push:
branches:
- master

jobs:
py-lint:
Expand Down Expand Up @@ -83,29 +86,39 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
components: llvm-tools-preview
override: true
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- id: prepare-container
name: Prepare docker container
run: docker compose up -d --wait
- id: setup-venv
name: Setup virtualenv
run: python -m venv .venv
- name: Build lib
uses: PyO3/maturin-action@v1
with:
command: dev --uv
sccache: true
run: uv venv
- name: Run pytest
run: |
set -e
source .venv/bin/activate
pytest -vv -n auto python/tests
source <(cargo llvm-cov show-env --sh)
export CARGO_TARGET_DIR="$CARGO_LLVM_COV_TARGET_DIR"
export CARGO_INCREMENTAL="1"
cargo llvm-cov clean --workspace
uv run -- maturin dev --uv
uv run -- pytest -vv python/tests --cov natsrpy --cov-report xml
cargo llvm-cov report --lcov --output-path coverage.lcov
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.lcov,coverage.xml
verbose: true
- name: Teardown docker
if: always()
run: docker compose down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ repos:
language: python
additional_dependencies:
- mypy
- maturin
entry: python ./scripts/stubtest.py
pass_filenames: false
always_run: true
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ thiserror = "2.0.18"
time = "0.3.47"
tokio = { version = "1.50.0", features = ["full"] }

[profile.dev]
opt-level = 0
lto = "off"
incremental = true

[profile.release]
lto = "fat"
codegen-units = 1
opt-level = 3
strip = true
debug = false
strip = true
lto = "fat"
panic = "abort"
codegen-units = 1
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,28 @@ As of for now, our documentation is only availabe in source code. You can see it
## Development

We use stable rust and pyo3 for writing python extension module.
In order to build the project, use uv and maturin.

In order to run the project use maturin:
uv is used for all python-side dependencies (including dev deps).
Maturin is used only for building rust-side.

```bash
# To create .venv folder
uv venv
# Sync deps
uv sync --locked
# To build and install the package in a virtual environment
maturin dev --uv
uv run -- maturin dev --uv
```

If you want to setup automatic rebuilds, use this command:

```bash
uv run -- python -m maturin_import_hook site install
```

It will force rebuild project when rust code changes.

For lints please use `pre-commit`.

```bash
Expand Down
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ classifiers = [
"Programming Language :: Rust",
"Topic :: System :: Networking",
]
dynamic = ["version"]
dependencies = [
"typing-extensions>=4.14.0",
"maturin-import-hook>=0.3.0",
"typing-extensions>=4.14.0",
]
dynamic = ["version"]

[[project.authors]]
name = "Pavel Kirilin"
Expand All @@ -25,16 +26,21 @@ email = "s3riussan@gmail.com"
[dependency-groups]
dev = [
"anyio>=4,<5",
"maturin>=1,<2",
"mypy>=1.19.1,<2",
"pre-commit>=4.5.1,<5",
"pytest>=9,<10",
"pytest-cov>=7,<8",
"pytest-xdist>=3,<4",
]

[build-system]
requires = ["maturin>=1.12,<2.0"]
build-backend = "maturin"

[tool.uv]
package = false

[tool.maturin]
bindings = "pyo3"
features = ["pyo3/extension-module"]
Expand Down
Loading
Loading