fix(node): gate pyo3 behind a python feature so the addon has no libpython - #31
Conversation
…ython Re-applies the change from #27, which was closed when main history was rewritten. The napi addon linked libpython on every platform because rustwright-core depends on pyo3 unconditionally: prebuilds only load on machines with the runner's exact Python, and the aarch64 zig cross-link fails outright (no libpython in the zig sysroot), blocking the npm release. - Cargo.toml: pyo3 optional; [features] default = ["python"], python = ["dep:pyo3"] - node/Cargo.toml: depend on the core with default-features = false - src/lib.rs: cfg-gate the pyo3 bindings; run_detached gets a pure fallback; create_page_raw/create_page_async/attach_existing_page return Arc<PageInner> so the FFI path never touches PyPage Verified: cargo check both feature configs (0 errors, 0 default warnings), cargo test 23/23, napi addon links only libiconv/libSystem (zero libpython/Python.framework strings) and smoke-drives a browser; maturin cp38-abi3 wheel builds and the python sync API launches chromium. Refs: SKY-12273 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K7b2PMrqsT9BJGaF6DFJA2
SummaryClean, well-scoped fix for a real blocking issue (aarch64 zig cross-link failure, libpython DT_NEEDED in prebuilds). The 🔴 Critical Issues (0)None. 🟡 Suggestions (2)
📝 Minor / Style (2)
|
|
Synced to rustwright-cloud: https://github.com/Skyvern-AI/rustwright-cloud/pull/20 |
## What Bump the version to 0.1.0-alpha.3 across all six version files (lockfiles regenerated via the toolchain). ## Why Release prerequisite for the first npm publish now that #31 removed the libpython linkage. PyPI already has 0.1.0a2 and the old tags were deleted in the history rewrite, so the release fixes forward to alpha.3; the tag will publish npm (first release, `next` dist-tag) and PyPI (alpha.3 with the pyo3 feature gating) together. Nothing publishes on merge; publishing is tag-gated and environment-approved. ## Testing - [x] cargo check --locked (all 8 version fields agree at 0.1.0-alpha.3) - [x] Full local battery ran on the parent commit (#31): cargo test 23/23, node addon builds with zero python linkage + smoke, maturin wheel + python API smoke ## Checklist - [x] I kept this change focused. - [x] I added or updated tests for behavior changes. (n/a: version-only) - [x] I did not include private credentials, tokens, or internal-only artifacts. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
What
Gate pyo3 behind a
pythoncargo feature (on by default) so the napi node addon builds without any Python linkage. Re-applies #27, which was closed when main history was rewritten.Cargo.toml: pyo3 optional;[features] default = ["python"],python = ["dep:pyo3"]node/Cargo.toml: consumes the core withdefault-features = falsesrc/lib.rs:#[cfg(feature = "python")]on the pyo3 bindings;run_detachedgets a pure fallback (its non-attached branch);create_page_raw/create_page_async/attach_existing_pagereturnArc<PageInner>so the FFI section never referencesPyPageWhy
Every napi prebuild links libpython today: the Linux x64 addon carries
DT_NEEDED libpython3.12.so.1.0and the macOS addon links the runner's Python.framework path, so published prebuilds would only load on machines with the runner's exact Python. The aarch64 zig cross-link fails outright (unable to find dynamic system library python3.8), which is what blocks the npm release. CI smoke passes only because runners have Python installed.Testing
cargo check --lockedwith default features and--no-default-features(0 errors; 0 warnings on default)cargo test --locked23/23npm run build+npm run smoke: addon drives a browser;otool -Lshows only libiconv/libSystem, zero libpython/Python.framework stringsmaturin build --release: cp38-abi3 wheel builds; fresh-venv install + sync API launches chromium and reads a titleChecklist