-
Notifications
You must be signed in to change notification settings - Fork 19
Prepare for pyo3 0.26 #54
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yep just waiting to fix some issues with trusted publishing and then hopefully the crates.io release will be live shortly!
Once I have it working, I'll send a PR here to configure trusted publishing too.
Just spotted a few things in this code where we can apply some TLC as we upgrade...
src/lib.rs
Outdated
static ASYNCIO: OnceCell<Py<PyAny>> = OnceCell::new(); | ||
static CONTEXTVARS: OnceCell<Py<PyAny>> = OnceCell::new(); | ||
static ENSURE_FUTURE: OnceCell<Py<PyAny>> = OnceCell::new(); | ||
static GET_RUNNING_LOOP: OnceCell<Py<PyAny>> = OnceCell::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should probably be updated to use the new PyOnceLock
(and PyOnceLock::import
, potentially).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some uses of OnceCell
:
pyo3-async-runtimes/src/tokio.rs
Line 69 in 74cd232
static TOKIO_RUNTIME: OnceCell<Pyo3Runtime> = OnceCell::new(); |
We could change them but then we'd also have to change the signatures of these public functions init_with_runtime
, get_runtime
, etc, to have a py: Python
argument.
pyo3-async-runtimes/src/tokio.rs
Lines 182 to 186 in 74cd232
pub fn init_with_runtime(runtime: &'static Runtime) -> Result<(), ()> { | |
TOKIO_RUNTIME | |
.set(Pyo3Runtime::Borrowed(runtime)) | |
.map_err(|_| ()) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, these ones which don't need Python can probably now be replaced with std::sync::OnceLock
, which is available after we bump MSRV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to remove almost all uses of once_cell
, except for
pyo3-async-runtimes/src/tokio.rs
Line 68 in 5e6c5b7
static TOKIO_BUILDER: Lazy<Mutex<Builder>> = Lazy::new(|| Mutex::new(multi_thread())); |
since it looks like
LazyLock
wasn't added to the stdlib until an MSRV of 1.80.
Can you shed some light on whether the CI failure is real?
It looks like the MSRV of pyo3 is now 1.74, while the MSRV of pyo3-async-runtimes is 1.63. Should we bump the MSRV here to match 1.74? |
Ah yes, let's bump MSRV to 1.74 to match 👍 |
Let me know if there's anything I can do to help get this merged! |
Trusted publishing and 3.14 support is now done in #55 |
It looks like this is ready for merge! @davidhewitt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I think I spotted one simplification, will push a commit and merge
Released, thanks all! |
It looks like a release of pyo3 0.26 is imminent.
Python::with_gil
withPython::attach
.pyo3::prepare_freethreaded_python();
withPython::initialize();
PyObject
withPy<PyAny>
This uses the git tag for pyo3 0.26 at the moment and will switch to the official crates.io version when 0.26 is published.
cc @davidhewitt