Skip to content

Commit f5d2d9e

Browse files
committed
chore: gate pyo3 extension module behind optional feature
1 parent ed81331 commit f5d2d9e

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

.agents/tasks/2025/08/18-1208-tracer-trait

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ artefact, it will be used only for testing.
7171

7272
Refer to the design-docs folder for the current planned design. Add/update files in the folder to match what was implemented in this task.
7373

74+
75+
--- FOLLOW UP TASK ---
76+
1. In codetracer-python-recorder/Cargo.toml, move pyo3’s extension-module feature to an optional crate feature and enable it only for release builds.
77+
2. Update Justfile (and CI scripts) to run cargo test --no-default-features so the test binary links with the Python C library.
78+
3. Add pyo3 with auto-initialize under [dev-dependencies] if tests require the interpreter to be initialized automatically.

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
nix_path: nixpkgs=channel:nixos-25.05
2222
extra_nix_config: |
2323
experimental-features = nix-command flakes
24+
- name: Run Rust tests
25+
run: nix develop --command bash -lc 'cargo test --manifest-path codetracer-python-recorder/Cargo.toml --no-default-features'
2426
- name: Build Rust module and run tests via Nix
2527
run: nix develop --command bash -lc 'just venv ${{matrix.python-version}} dev test'
2628

Justfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ dev:
3232
uv run --directory codetracer-python-recorder maturin develop --uv
3333

3434
# Run unit tests of dev build
35-
test:
35+
test: cargo-test
3636
uv run --group dev --group test pytest
3737

38+
# Run Rust unit tests without default features to link Python C library
39+
cargo-test:
40+
cargo test --manifest-path codetracer-python-recorder/Cargo.toml --no-default-features
41+
3842
# Run tests only on the pure recorder
3943
test-pure:
4044
uv run --group dev --group test pytest codetracer-pure-python-recorder

codetracer-python-recorder/Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ repository = "https://github.com/metacraft-labs/codetracer-python-recorder"
1010
name = "codetracer_python_recorder"
1111
crate-type = ["cdylib"]
1212

13+
[features]
14+
extension-module = ["pyo3/extension-module"]
15+
default = ["extension-module"]
16+
1317
[dependencies]
14-
pyo3 = { version = "0.25.1", features = ["extension-module"] }
15-
runtime_tracing = "0.14.0"
18+
pyo3 = { version = "0.25.1" }
19+
runtime_tracing = "0.14.0"
20+
21+
[dev-dependencies]
22+
pyo3 = { version = "0.25.1", features = ["auto-initialize"] }

0 commit comments

Comments
 (0)