Skip to content

Commit 4582fad

Browse files
authored
bump main pyo3 and gate stub generation (#111)
1 parent 96a6754 commit 4582fad

33 files changed

Lines changed: 227 additions & 161 deletions

File tree

‎.github/workflows/release-rust-python-package.yaml‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,9 @@ jobs:
147147
rustc --version
148148
cargo --version
149149
150-
- name: Generate stubs
150+
- name: Verify stubs are checked in
151151
working-directory: ${{ needs.resolve.outputs.plugin_path }}
152-
run: cargo run --bin stub_gen
153-
154-
- name: Verify generated stubs are checked in
155-
working-directory: ${{ needs.resolve.outputs.plugin_path }}
156-
run: git diff --exit-code
152+
run: test -n "$(find . -name '*.pyi' -print -quit)"
157153

158154
build-wheel:
159155
needs: [resolve, preflight]

‎.secrets.baseline‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.lock‎

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ repository = "https://github.com/IBM/cpex-plugins"
2020
cpex_framework_bridge = { path = "crates/framework_bridge" }
2121
criterion = { version = "0.8.2", features = ["html_reports"] }
2222
log = "0.4.29"
23-
pyo3-async-runtimes = { version = "0.28.0", features = ["tokio-runtime"] }
24-
pyo3 = { version = "0.28.3", features = ["abi3-py311"] }
25-
pyo3-log = "0.13.3"
26-
pyo3-stub-gen = "0.22.2"
23+
pyo3-async-runtimes = { version = "0.29.0", features = ["tokio-runtime"] }
24+
pyo3 = { version = "0.29.0", features = ["abi3-py311"] }
25+
pyo3-log = "0.13.4"
26+
pyo3-stub-gen = "0.22.3"
2727
regex = "1.12.3"
2828
serde_json = "1.0.149"
2929
thiserror = "2.0.18"

‎deny.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# pyo3-stub-gen 0.22.1 still pulls rustpython-parser's unmaintained unic-* parser crates.
66
# Keep this scoped to the known transitive advisories so new unmaintained dependencies fail CI.
77
ignore = [
8+
{ id = "RUSTSEC-2026-0176", reason = "pyo3-stub-gen blocks PyO3 0.29 until upstream compatibility release; expires 2026-06-29" },
9+
{ id = "RUSTSEC-2026-0177", reason = "pyo3-stub-gen blocks PyO3 0.29 until upstream compatibility release; expires 2026-06-29" },
810
"RUSTSEC-2025-0075", # unic-char-range via rustpython-parser
911
"RUSTSEC-2025-0080", # unic-common via rustpython-parser
1012
"RUSTSEC-2025-0081", # unic-char-property via rustpython-parser

‎plugins/rust/python-package/encoded_exfil_detection/Cargo.toml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ crate-type = ["cdylib", "rlib"]
1414
[[bin]]
1515
name = "stub_gen"
1616
path = "src/bin/stub_gen.rs"
17+
required-features = ["stub-gen"]
18+
19+
[features]
20+
default = []
21+
stub-gen = ["dep:pyo3-stub-gen"]
1722

1823
[dependencies]
1924
base64 = "0.22.1"
2025
cpex_framework_bridge = { workspace = true }
2126
log = { workspace = true }
2227
pyo3 = { workspace = true }
2328
pyo3-log = { workspace = true }
24-
pyo3-stub-gen = { workspace = true }
29+
pyo3-stub-gen = { workspace = true, optional = true }
2530
regex = { workspace = true }
2631
serde_json = { workspace = true }
2732

‎plugins/rust/python-package/encoded_exfil_detection/Makefile‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ test-integration:
6262

6363
test-all: test
6464

65-
verify-stubs: stub-gen
66-
@git diff --exit-code -- $(STUB_FILES)
65+
verify-stubs:
66+
@test -f cpex_encoded_exfil_detection/__init__.pyi
67+
@test -f cpex_encoded_exfil_detection/encoded_exfil_detection_rust/__init__.pyi
6768

6869
# help: stub-gen - Generate Python type stubs (.pyi files)
6970
# help: build - Build release wheel (no install)
@@ -73,15 +74,15 @@ verify-stubs: stub-gen
7374

7475
stub-gen:
7576
@echo "$(GREEN)Generating Python type stubs...$(NC)"
76-
$(CARGO) run --bin stub_gen
77+
$(CARGO) run --features stub-gen --bin stub_gen
7778
@echo "$(GREEN)Stubs generated$(NC)"
7879

79-
build: stub-gen
80+
build:
8081
@echo "$(GREEN)Building $(PACKAGE_NAME)...$(NC)"
8182
uv run maturin build --release
8283
@echo "$(GREEN)Build complete$(NC)"
8384

84-
install: stub-gen
85+
install:
8586
@echo "$(GREEN)Installing $(PACKAGE_NAME)...$(NC)"
8687
uv run maturin develop --release
8788
@echo "$(GREEN)Installation complete$(NC)"

‎plugins/rust/python-package/encoded_exfil_detection/src/lib.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use base64::Engine;
22
use base64::engine::general_purpose::{STANDARD, URL_SAFE};
33
use pyo3::prelude::*;
44
use pyo3::types::{PyAny, PyDict, PyList, PyMapping, PyString, PyTuple};
5+
#[cfg(feature = "stub-gen")]
56
use pyo3_stub_gen::define_stub_info_gatherer;
7+
#[cfg(feature = "stub-gen")]
68
use pyo3_stub_gen::derive::*;
79
use regex::Regex;
810
use std::collections::HashMap;
@@ -821,13 +823,13 @@ fn scan_container<'py>(
821823
}
822824

823825
/// Persistent engine that parses config once at init and reuses it across scans.
824-
#[gen_stub_pyclass]
826+
#[cfg_attr(feature = "stub-gen", gen_stub_pyclass)]
825827
#[pyclass]
826828
struct ExfilDetectorEngine {
827829
cfg: DetectorConfig,
828830
}
829831

830-
#[gen_stub_pymethods]
832+
#[cfg_attr(feature = "stub-gen", gen_stub_pymethods)]
831833
#[pymethods]
832834
impl ExfilDetectorEngine {
833835
#[new]
@@ -847,7 +849,7 @@ impl ExfilDetectorEngine {
847849
}
848850

849851
/// Backward-compatible bare function — creates a temporary engine per call.
850-
#[gen_stub_pyfunction]
852+
#[cfg_attr(feature = "stub-gen", gen_stub_pyfunction)]
851853
#[pyfunction]
852854
fn py_scan_container<'py>(
853855
py: Python<'py>,
@@ -866,6 +868,7 @@ fn encoded_exfil_detection_rust(m: &Bound<'_, PyModule>) -> PyResult<()> {
866868
}
867869

868870
// Define stub info gatherer for generating Python type stubs
871+
#[cfg(feature = "stub-gen")]
869872
define_stub_info_gatherer!(stub_info);
870873

871874
#[cfg(test)]

‎plugins/rust/python-package/pii_filter/Cargo.toml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ crate-type = ["cdylib", "rlib"]
1414
[[bin]]
1515
name = "stub_gen"
1616
path = "src/bin/stub_gen.rs"
17+
required-features = ["stub-gen"]
18+
19+
[features]
20+
default = []
21+
stub-gen = ["dep:pyo3-stub-gen"]
1722

1823
[dependencies]
1924
cpex_framework_bridge = { workspace = true }
2025
log = { workspace = true }
2126
pyo3 = { workspace = true }
2227
pyo3-log = { workspace = true }
23-
pyo3-stub-gen = { workspace = true }
28+
pyo3-stub-gen = { workspace = true, optional = true }
2429
regex = { workspace = true }
2530
once_cell = "1.21.4"
2631
serde = { workspace = true }

0 commit comments

Comments
 (0)