Skip to content

fix: resolve PyO3 extension-module linking for cargo test and maturin builds#24

Merged
pratyush618 merged 1 commit intomasterfrom
fix/extension-module-maturin
Mar 11, 2026
Merged

fix: resolve PyO3 extension-module linking for cargo test and maturin builds#24
pratyush618 merged 1 commit intomasterfrom
fix/extension-module-maturin

Conversation

@pratyush618
Copy link
Owner

Problem

Two interacting issues caused builds to break:

  1. CI rust-testcargo test --workspace failed with undefined Py_* symbols because extension-module was always-on in workspace pyo3 features, telling PyO3 not to link libpython. Test executables need libpython linked.

  2. Publish workflow (maturin builds) — After fixing (1) by removing extension-module from workspace defaults, maturin builds broke. Maturin specially handles "pyo3/extension-module" in pyproject.toml features by stripping it from --features and setting PYO3_BUILD_EXTENSION_MODULE=1 via env instead. Without extension-module in workspace defaults, the cargo feature was never activated and pyo3 tried to link libpython (cannot find -lpython3.9).

Fix

  • Cargo.toml — Remove extension-module from workspace pyo3 features
  • crates/taskito-python/Cargo.toml — Add extension-module = ["pyo3/extension-module"] as an explicit crate feature
  • pyproject.toml — Change "pyo3/extension-module""extension-module" in maturin features so maturin passes it as a normal cargo feature (activating pyo3/extension-module through the crate feature, not via env var)
  • .github/workflows/ci.yml — Add Python setup + LD_LIBRARY_PATH to rust-test so cargo test --workspace can link libpython

Result: maturin builds activate pyo3/extension-module (no libpython linking, correct for .so). cargo test runs without that feature and links libpython normally.

@pratyush618 pratyush618 merged commit a4eea4a into master Mar 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant