Skip to content
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

Error on prepare_freethreaded_python in crate pyo3 on OSX Big Sur #1718

Closed
sansyrox opened this issue Jul 5, 2021 · 6 comments
Closed

Error on prepare_freethreaded_python in crate pyo3 on OSX Big Sur #1718

sansyrox opened this issue Jul 5, 2021 · 6 comments

Comments

@sansyrox
Copy link
Contributor

sansyrox commented Jul 5, 2021

🐛 Bug Reports

When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.

I am getting the error : prepare_freethreaded_python in crate pyo3 on OSX Big Sur when I am using the prepare_freethreaded_python function.

I also opened an issue(#1686) earlier, it was fixed then but it is not working with the latest release.

🌍 Environment

  • Your operating system and version: OSX Big Sur
  • Your python version: 3.9
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?:
  • Your Rust version (rustc --version): 1.50.0 (cb75ad5db 2021-02-10
  • Your PyO3 version: 0.13.2
  • Have you tried using latest PyO3 main (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?:

💥 Reproducing

Please provide a minimal working example. This means both the Rust code and the Python.

use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

use std::future::Future;

#[pymodule]
pub fn robyn(py: Python<'_>, m: &PyModule) -> PyResult<()> {
    pyo3_asyncio::try_init(py).unwrap();
    pyo3::prepare_freethreaded_python();

    Ok(())
}


Error message:

error[E0425]: cannot find function `prepare_freethreaded_python` in crate `pyo3`
  --> src/lib.rs:29:11
   |
29 |     pyo3::prepare_freethreaded_python();
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `pyo3`

My toml file

[lib]
name = "robyn"
crate-type = ["cdylib", "rlib"]


[dependencies]
tokio = { version = "1.7.0", features = ["full"] }
dashmap = "4.0.2"
hyper = { version="0.14.9", features = ["full"]}
anyhow = "1.0.38"
notify = "4.0.0"
pyo3 = { version = "0.14.1", features = ["extension-module"] }
pyo3-asyncio = { version = "0.13", features = ["attributes", "tokio-runtime"] }
async-std = "1.9"

[patch.crates-io]
pyo3 = {git = "https://github.com/PyO3/pyo3/",branch = "main", features = ["extension-module"]}

Please also write what exact flags are required to reproduce your results.

@davidhewitt
Copy link
Member

Can you reproduce this without pyo3-asyncio? This function will now always be present unless you are using PyPy, so I suspect build configuration error.

@sansyrox
Copy link
Contributor Author

sansyrox commented Jul 5, 2021

@davidhewitt , it's working now. I had to run cargo update and it started to work. But now I have a different issue:

🍹 Building a mixed python/rust project
💥 maturin failed
  Caused by: Expected exactly one pyo3 dependency, found 2

@sansyrox
Copy link
Contributor Author

sansyrox commented Jul 5, 2021

Can you reproduce this without pyo3-asyncio? This function will now always be present unless you are using PyPy, so I suspect build configuration error.

It works without pyo3-asyncio but gives the above error with it.

@davidhewitt
Copy link
Member

Yeah, you won't be able to build with pyo3-asyncio until it releases an update to PyO3 0.14.

I'm going to close this issue as the problem is in dependencies not being ready.

@sansyrox
Copy link
Contributor Author

sansyrox commented Jul 5, 2021

@davidhewitt , is there a possible way to build it with older version maybe the previous version and use pyo3-asyncio with it?

@davidhewitt
Copy link
Member

In PyO3 0.13 you'll experience this issue if your interpreter is not built with Py_ENABLE_SHARED. See #763 for a note how to install python on Mac with a shared library.

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

No branches or pull requests

2 participants