You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use #[pymethods] in my project, cargo test no longer compiles.
π Environment
Your operating system and version:
β Linux Ubuntu 19.10
Your python version:
β Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008] on linux
How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?
β I installed python3 with apt, and use it from a venv
Your rust version (rustc --version):
β rustc 1.42.0 (b8cedc004 2020-03-09)
Are you using the latest pyo3 version? Have you tried using latest master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?
β I tried both
π₯ Reproducing
I started with the simple example given here, and added a test module. cargo +nightly test runs fine.
I then added
#[pyclass]pubstructFoo{}#[pymethods]implFoo{}
and cargo +nightly test still runs fine.
But as soon as I add a function even doing nothing (pub fn foo() {}) in the impl block, cargo +nightly test gives me the compilation error below. Note that cargo +nightly build still works fine.
Compilation error:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.109hleyh2kp0fsyr.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.10dkyc5kd9ymq73s.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.17quxwlbrqw8hj7s.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1l1b084h09aptdzo.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1lkhs9iu8wspfkhf.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1tcmqx3sh5gyqj6t.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1u6vlfjgt6wio4lf.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1wfkrdcmhd0whgdg.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.1zv6gwij13dpfn7z.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2001hl8uuc4y81bo.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.236617qglm5yim3e.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2678j2qn322y5300.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.28n31dnuutnz8nvi.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2952miup9uwgv41l.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.29wcml04ji4c5bbr.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2c1scr6irhr136e9.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2gb5mkukcl7wgu4y.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2ma0nsfwxja118p0.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2w014i84gnlsprgs.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2x5w2tzty48bxje3.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2yd1o35s5xap7vab.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.31boqiy4lltzvs9n.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.34t2sm4va5o8rk.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.366raiq0lz40zp.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3asnyr45w8pichcv.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3befyxmor2kkdft2.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3j29qwiii5c8sip1.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3ki8y7i2r6i4an6f.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3thhymiru7psgb3y.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3v1ls757czydoeju.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3v2yvtz7befxts8v.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.3ynedg6e3b3v732d.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.411cgqrcxt42r1mk.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.43s7tvv0w42w4oun.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.45pn5owcijeiri51.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.494f42qd5punoiez.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.4g4yebi4qwfkec58.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.4lv2rq299mlu7pne.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.4wrwi7gyfp9r1xm.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.4zn2ep2tlkijbz0e.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.52hm7meb4t4rbi0e.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.55go9xoi3bec2pa3.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.55yxgqbp2yk0vcsj.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.58di4ncs82owc9sw.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.59esv7vihzc7lh53.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.5c2n2zl3040u3pod.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.5ce9b6o05cwica41.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.5cw9wv05c0el02f0.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.5eahuwbut371kzph.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.8q7czd6l8m9lblx.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.h7rc8s4f3pmt8lm.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.ljyeefxcnm5fgdw.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.pgj76pv82n7h4dd.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.wc1d6gatqnk4xxx.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.xy38jrqqijayk8z.rcgu.o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.z80n0bfar9kbqxg.rcgu.o" "-o" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0" "/home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.16944yh97yo1rkmx.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/pa/tmp/test_pyo3/target/debug/deps" "-L" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-8a232aaa4454fc17.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-9635ba058a6160dc.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-931b34d451d8130e.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-29248e68b923678e.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-376d95deefd17798.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libparking_lot-2bf5336fc56f76af.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libparking_lot_core-c3a7647ed7ed5765.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libcfg_if-1c7f54a97c5ff6c5.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libsmallvec-d167b13726385e4a.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/liblock_api-d702a9963fb46fca.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libscopeguard-53e4b3a35014edc9.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libnum_traits-b79287dec04ed2f9.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libunindent-5ce5fd00d38e4c89.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/liblibc-21dfdb5f02666556.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libinventory-9b772211fa0028ee.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libindoc-8270e20bc513f675.rlib" "/home/pa/tmp/test_pyo3/target/debug/deps/libpaste-8f554db8ac103451.rlib" "-Wl,--start-group" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-08d9f9dbf3ce8ba6.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-c8bbb97721eece57.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-f915ad27f26cc43a.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-ba963b08c33add93.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-073a5442c7e05cbd.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-9a15745a8e512430.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-5ebca2692bc4c1c4.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-1411abf081cbe734.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-79269dab5354ed4f.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-a27c87eea3474d78.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f42bfa01fbd99718.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-882aa800a25c0b7c.rlib" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-a2ab15a95dc279ee.rlib" "-Wl,--end-group" "/home/pa/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b12142e6382b96eb.rlib" "-Wl,-Bdynamic" "-lutil" "-ldl" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
= note: /usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/test_pyo3-41ae250cadef73a0.2678j2qn322y5300.rcgu.o: in function `pyo3::err::PyErr::restore':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/err.rs:345: undefined reference to `PyErr_Restore'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.0.rcgu.o): in function `pyo3::err::PyErr::new_type':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/err.rs:209: undefined reference to `PyErr_NewException'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.0.rcgu.o): in function `pyo3::err::panic_after_error':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/err.rs:552: undefined reference to `PyErr_Print'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.1.rcgu.o): in function `pyo3::gil::prepare_freethreaded_python::{{closure}}':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/gil.rs:39: undefined reference to `Py_IsInitialized'
/usr/bin/ld: /home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/gil.rs:57: undefined reference to `Py_InitializeEx'
/usr/bin/ld: /home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/gil.rs:68: undefined reference to `PyEval_SaveThread'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.1.rcgu.o): in function `<pyo3::gil::GILGuard as core::ops::drop::Drop>::drop':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/gil.rs:111: undefined reference to `PyGILState_Release'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.1.rcgu.o): in function `pyo3::gil::GILGuard::acquire':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/gil.rs:235: undefined reference to `PyGILState_Ensure'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.13.rcgu.o): in function `pyo3::ffi::object::Py_DECREF':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/ffi/object.rs:931: undefined reference to `_Py_Dealloc'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.13.rcgu.o): in function `pyo3::ffi::object::Py_None':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/ffi/object.rs:973: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /home/pa/tmp/test_pyo3/target/debug/deps/libpyo3-3d7cd1cf4d05e29b.rlib(pyo3-3d7cd1cf4d05e29b.pyo3.1adzdfmu-cgu.15.rcgu.o): in function `<pyo3::exceptions::RuntimeError as pyo3::type_object::PyTypeObject>::type_object':
/home/pa/.cargo/git/checkouts/pyo3-a22e69bc62b9f0fd/1aa4ae8/src/exceptions.rs:218: undefined reference to `PyExc_RuntimeError'
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered:
π Bug Reports
When I use
#[pymethods]
in my project,cargo test
no longer compiles.π Environment
β Linux Ubuntu 19.10
β Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008] on linux
β I installed python3 with apt, and use it from a venv
rustc --version
):β rustc 1.42.0 (b8cedc004 2020-03-09)
version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
β I tried both
π₯ Reproducing
I started with the simple example given here, and added a
test
module.cargo +nightly test
runs fine.I then added
and
cargo +nightly test
still runs fine.But as soon as I add a function even doing nothing (
pub fn foo() {}
) in theimpl
block,cargo +nightly test
gives me the compilation error below. Note thatcargo +nightly build
still works fine.Compilation error:
The text was updated successfully, but these errors were encountered: