New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link errors on macOS when a dependency which also uses pyo3 has a cdylib target #1080
Comments
I think it's because we are using |
See also PyO3/setuptools-rust#235 |
Any workarounds for this? |
@mlucool If you mean deshaw/nbstripout-fast#3 you can feature-gate the [dependencies]
pyo3 = "0.17.3"
[features]
default = ["extension-module"]
extension-module = ["pyo3/extension-module"] Then you can build |
@messense I tried feature-gating the python bindings as you said by setting # Cargo.toml
[features]
default = ["extension-module"]
extension-module = ["pyo3/extension-module"] and # pyproject.toml
[tool.maturin]
bindings = "bin" to match what you suggested above. When I tried to build the project using
In summary, I wasn't able to get |
@peytondmurray Have you tried override bindings type in cli? |
@messense Thanks for the help - overriding the bindings type in CLI does work, but I'm still getting macOS build issues using
but the build still fails at the linking stage for binary output 🤔. I can keep poking around with this, maybe there's something else I'm doing wrong here. I'm also not sure if this helps, but |
Not sure why, but with some debugging it show that even when which in turn causes cc @davidhewitt Reproduce steps: git clone https://github.com/peytondmurray/nbstripout-fast.git
cd nbstripout-fast
git checkout add-bin
maturin build --no-default-features
$ PYO3_PRINT_CONFIG=1 maturin build --no-default-features
📦 Including license file "/Users/messense/Projects/nbstripout-fast/LICENSE.txt"
🐍 Found CPython 3.11 at /Users/messense/.pyenv/versions/3.11.0/bin/python3
📡 Using build options bindings from pyproject.toml
Compiling pyo3-ffi v0.16.6
error: failed to run custom build command for `pyo3-ffi v0.16.6`
Caused by:
process didn't exit successfully: `/Users/messense/Projects/nbstripout-fast/target/debug/build/pyo3-ffi-2eeeb1eb9310c032/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=PYO3_CROSS
cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG
-- PYO3_PRINT_CONFIG=1 is set, printing configuration and halting compile --
implementation=CPython
version=3.11
shared=true
abi3=false
lib_name=python3.11
lib_dir=/Users/messense/.pyenv/versions/3.11.0/lib
executable=/Users/messense/.pyenv/versions/3.11.0/bin/python3
pointer_width=64
build_flags=
suppress_build_script_link_lines=false
note: unset the PYO3_PRINT_CONFIG environment variable and retry to compile with the above config
💥 maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit status: 101": `"cargo" "rustc" "--no-default-features" "--manifest-path" "/Users/messense/Projects/nbstripout-fast/Cargo.toml" "--message-format" "json" "--bin" "nbstripout-fast"` |
xref rust-lang/cargo#9235
|
For future reference, i've confirmed that changing - name: Build wheels - x86_64
uses: PyO3/maturin-action@v1
with:
target: x86_64 to - name: Build wheels - x86_64
uses: PyO3/maturin-action@v1
with:
target: x86_64
env:
RUSTFLAGS: "-C link-arg=-undefined -C link-arg=dynamic_lookup" is a workaround I'm not sure where to document that properly, it's definitely a rare problem. |
Bug Description
I have two crates, cell and mitochondria, where cell depends on mitochondria. Each has pyo3 bindings on its own. If mitochondria has
cdylib
ascrate-type
, trying tomaturin build
on mac os will fail with pyo3 linker errors, with only the default crate-typerlib
or on ubuntu and windows it works. I've made a minimal example with github actions at https://github.com/konstin/maturin-mac-os-dep-repro.The error looks like it's missing the
link-arg=-undefined
/link-arg=dynamic_lookup
, even though they are present and work for the top level crate.Your Python version (
python -V
)3.8
Your pip version (
pip -V
)22.2.2
What bindings you're using
pyo3
Does
cargo build
work?n/a, this is a linker error
If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash
/
)?Steps to Reproduce
See minimal example at https://github.com/konstin/maturin-mac-os-dep-repro
Ubuntu, passing: https://github.com/konstin/maturin-mac-os-dep-repro/runs/8144523404?check_suite_focus=true
Mac os, failing: https://github.com/konstin/maturin-mac-os-dep-repro/runs/8144523536?check_suite_focus=true
The text was updated successfully, but these errors were encountered: