-
Notifications
You must be signed in to change notification settings - Fork 733
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
dyld: Symbol not found: _PyExc_SystemError
in tests if there is #[pymethods]
in project
#340
Comments
Thanks for reporting! [dependencies.pyo3]
features = [] to test project. |
As workaround I added |
First of all, thank you for the test repository! As @kngwyu said, we need to deactivate features for the tests. A proper solution for this requires rust-lang/cargo#2911, which unfortunately is unlikely to be implemented soon. For now, you can use the following as workaround:
Tests can then be run with With a bit context this workaround would be very useful in the guide. |
Thanks for help! |
Just ran into this issue - thank you both for posting really great instructions on how to work around this. |
BTW this is also in the guide: https://pyo3.rs/v0.7.0-alpha.1/advanced.html#testing |
The work-around mentioned in #340 (comment) does not work if the test is run on a workspace where one of member crates uses PyO3. |
I'm getting this error as well, however I'm not using use pyo3::prelude::*;
#[pymodule]
fn travertine(_py: Python, _m: &PyModule) -> PyResult<()> {
Ok(())
}
#[cfg(test)]
mod test {
use super::*;
use pyo3::types::{IntoPyDict, PyDateTime};
#[test]
fn pydelta_conversion() {
let gil = Python::acquire_gil();
let py = gil.python();
let datetime = py.import("datetime").unwrap();
let locals = [("datetime", datetime)].into_py_dict(py);
let now: &PyDateTime = py
.eval("datetime.datetime.utcnow()", None, Some(&locals))
.unwrap()
.downcast()
.unwrap();
println!("{:?}", now);
}
} That suffices to trigger the error. The entire repository is in https://github.com/mvaled/pyo3bug340 The issue is reproducible with stable version of pyo3. |
Yes. TBH this issue is (I believe) really a dupe of #771 |
Maybe we're going around this the wrong way, maybe when maturin builds it should add in --features=pyo3/extension-module because it knows it's required. That way the cargo test would just work. We can already do:
Why not add that flag in automatically if it's clear that it's not there? Having pyo3/extension-module turned on as a default feature seems like a footgun as people will just run cargo test and expect stuff to work on cli, IDEs etc. I've posted this in the maturin issues list here: |
The bindings module does not play nicely with cargo test. Fortunatley, it's functionality is tested with pytest, and the module is not required when testing the core module. The test suite can now be ran with: `cargo test --features "test"` Workaround for: PyO3/pyo3#340 which allows for doctests. Source of workaround: rust-lang/rust#45599
I just ran into this problem also. I had quite an extensive project which was working fine with Rolling back removed the issue and I tried to remake the changes to identify the cause but couldn't unfortunately. This was particularly confusing after appearing on a reasonably developed project and apparently after rather innocuous changes. |
… On Tue, Mar 26, 2024 at 2:22 AM JHM Darbyshire ***@***.***> wrote:
I just ran into this problem also. I had quite an extensive project which
was working fine with cargo test --lib. A few commits later and the cc
linker issue came up on my both my different Macs. The changes made did not
seem to be that significant, and certainly not as obvious as the original
post assumes some attachment of [pymethods]: I had these already working
well so this was not the cause.
Rolling back removed the issue and I tried to remake the changes to
identify the cause but couldn't unfortunately.
This was particularly confusing after appearing on a reasonably developed
project and apparently after rather innocuous changes.
—
Reply to this email directly, view it on GitHub
<#340 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBBI6JT4FQ77L5OKO7DY2EA2JAVCNFSM4GUTIVYKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBRHE2DQNZYGEZA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
@davidhewitt @alex I've been reading about this problem in the FAQ and related issues, and couldn't find any mentions or examples of running PyO3 code from a Rust test in a PyO3 lib. For reference, I created a new hello world project with the exact steps from the Getting started guide, then added this to [features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"] And then added this simple test to the #[cfg(test)]
mod tests {
#[test]
fn test() {
// pyo3::Python::with_gil(|py| {}); // uncommenting this breaks tests
assert_eq!(1, 1);
}
} Running 1 This is also weird by the way, because according to the FAQ, for the configuration I set above, I should call |
@glevco good catch! There may be some inconsistency in docs I guess. Also the flag seems to be required for |
Tests fail with error when there are methods in
#[pymethods]
impl
for struct:🌍 Environment
brew install python3
. I used virtualenv via pipenvrustc --version
): 1.34.0-nightly (8ae730a44 2019-02-04)version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
I use 0.6.0-alpha.2. With latest master error is the same.💥 Reproducing
Run
cargo test
for the following code:Also i created minimal project for reproducing the issue: https://github.com/deaz/pyo3-test
The text was updated successfully, but these errors were encountered: