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
Reacted by Kipton Barros, Roman Yurchak, Justin Austin, Dror Levin, lvxejay, nohar, Romuald Texier-Marcadé, jimy byerley, Jaanus Varus, Greg Price and 28 more
The foo_internal__stringify_const function receives original code and returns generated code. You get a token stream using syn crate as with macros 1.1.
And all this works by wrapping a body of the macro into a type definition to leverage macros 1.1, to get a token stream.
I see. But that would be quite large task, I don’t think I can spend any time on it. Also there is specialization, I am not sure if it possible to avoid it
If you want to work on this task I can give you permission to repo
impl<'source> $crate::std::convert::TryFrom<&'source $crate::PyObjectRef> for $t
The macro pyobject_extract! uses TryFrom. To use PyO3 in stable rust, this library itself must be compiled with stable rustc.
IMHO, there is no merit to use this unstable feature, and should be dropped.
@termoshtt Good catch! pyo3 implements TryFrom, even though it currently uses PyTryFrom instead. I put a feature gate onto the implementation of TryFrom and removed the try_from feature. Once TryFrom becomes stable, we can than replace PyTryFrom.
Drop of fn_must_use in afcc87e causes many warnings
warning: `#[must_use]` on methods is experimental (see issue #43302)
--> src/typeob.rs:154:5
|
154 | #[must_use]
| ^^^^^^^^^^^
|
= help: add #![feature(fn_must_use)] to the crate attributes to enable
Progress slowly continues; we want to get there but need more volunteer time to get this over the finish line yet. (pyo3 maintainer time in the last few months has been spent mostly on soundness problems as well as bugfixes, which are also very important.)
Last items to resolve are in #697. I can offer mentoring advice to anyone interested in helping out with pieces of the solution in there.
@jcdyer The emphasis is on easy interoperability, not just any interoperability, which is the purpose of PyO3. That being said, I did pitch rust to my coworkers, and got enough leeway to experiment with it in a side project - because I realized that nightly wasn't as bad as it sounded.
That being said, I work in a research lab not an enterprise company and our risk tolerance for these sorts of things is significantly higher, so continuing to focus on using stable would be a big selling point for the language overall. Glad to see how active this community is - it says a lot about the language and ecosystem :)
Hello. It appears to me, from reading #210, that specialisisation is mostly used to implement class declaration. So how hard would it be to introducing a feature no-unstable-class-support to pyo3 that simply switches off class declaration, but allows code to be compiled on stable rust? People that want to use pyo3 instead of rust-cpython and can live without classes could then do so without having to use unstable.
Once specialisation is stable or pyo3 managed to get rid of it, class declaration would be allowed in no-unstable-class-support and the feature would become identical to the default configuration again. I think this would also be very much in line on how rustc itself adds new features.
An alternative would be the other way around: Make no-unstable-class-support the default and introduce a feature allow-unstable-class-support.
if we're going to use a cargo feature, we should use the enable unstable code feature rather than the disable version, since cargo features should be additive since that's how cargo's designed.
as an example, if one crate uses the unstable code and another one doesn't, then using the enable version of the feature would correctly deduce that unstable code should be enabled for the crate that requires it. if it was the disable version then cargo would incorrectly disable the unstable code even though a crate requires it, leading to compile failure.
If anything requires unstable code, then you need to use the unstable compiler on all the crates anyway in order to have the compiler versions match, so that's not a limitation.
Reacted by David Hewitt, nacaclanga, David Clevenger and Andrew Wagner
Make sense. The reason I thought it up the other way round is, that it might make things appear from the documentation, but one should be able to work around this.
Hi. I don't know a lot about Rust, but trying to run an application I use often that recently introduced bits of rust.
Why can't PyO3 work with Rust 1.43.1, released last week? My OS ships stable rust. This ticket is 3 years old now, this is annoying.
Reacted by Gustavo J. A. M. Carneiro
Reacted by David Hewitt, Diana, Joshua Adelman, Sunjay Varma, Julia Tatz, Sergey, io, Shirshak and Nicole L
@sinetek The answer to the question you asked is in the thread above.
If you would like to get it working, the recommended way to work with rust as a developer is to use rustup to manage your rust toolchains, so you can have nightly and stable running side by side. You can get rustup from https://rustup.rs.
Then when you want do run on stable, you can switch back with rustup default stable. You can also set per-directory overrides with rustup override. Run rustup override --help for details.
For all those following this thread... the current PyO3 master branch just had a PR merged which added support for stable Rust.
Extra special thanks to @kngwyu and @konstin who have been working to remove specialization from PyO3 for a long time - and as of this morning, we finally got there! 🎉 🚀 🐍 🦀
Reacted by Benjamin Levy, tesuji, Fabio Colella, Tobias Bergkvist, extraymond, Sergey A., Luo Jia / Zhouqi Jiang, Weihang Lo, Tobias, Gabriele Belluardo and 46 more
Reacted by Achyut-BK
Reacted by Benjamin Levy, Kenta Kubo, Thomas Herzog, fly, Olli Paakkunainen, Fabio Colella, Tobias Bergkvist, Alexander Niederbühl, Matt Williams, Daniel Julius Lasiman and 60 more
Reacted by Benjamin Levy, Chris Barnes, Weihang Lo, Tobias, Sunjay Varma, Léo Lanteri Thauvin, Samuel Batissou Tiburcio, Emma Smith, Anton Barkovsky, seanjensengrey and 14 more
Reacted by Benjamin Levy, Alexander Hirner, Fabio Colella, David Hewitt, Sergey A., Jaanus Varus, Weihang Lo, Jack O'Connor, Tobias, Fabian and 22 more
Activity
[-]Stable rust[/-][+]Compile with stable rust[/+]tailhook commentedon Jul 26, 2017
Doesn't proc macro work on stable rust? (or just partially) And there is proc-macro2
messense commentedon Jul 26, 2017
I think currently only proc macro for custom derive works on stable Rust,
proc_macro_attributedon't.fafhrd91 commentedon Jul 26, 2017
proc_macro_attributeis unstable, info is in linked tracking issue.tailhook commentedon Dec 2, 2017
Can this trick be used instead of
proc_macro_attribute?fafhrd91 commentedon Dec 2, 2017
no, it is not. pyo3 strictly requires
proc_macro_attribute, because it requires access to token stream of impl sections.tailhook commentedon Dec 2, 2017
I think this is exactly what it does, i.e. given the example:
The
foo_internal__stringify_constfunction receives original code and returns generated code. You get a token stream usingsyncrate as with macros 1.1.And all this works by wrapping a body of the macro into a type definition to leverage macros 1.1, to get a token stream.
The only difference is that:
Would be written as:
fafhrd91 commentedon Dec 2, 2017
I see. But that would be quite large task, I don’t think I can spend any time on it. Also there is specialization, I am not sure if it possible to avoid it
If you want to work on this task I can give you permission to repo
fafhrd91 commentedon Feb 15, 2018
this features are stable now, const_unsafe_cell_new, const_size_of, const_ptr_null, const_ptr_null_mut
termoshtt commentedon May 3, 2018
Stabilization of TryFrom has been reverted rust-lang/rust#50121
fafhrd91 commentedon May 3, 2018
pyo3 does not use TryFrom
termoshtt commentedon May 4, 2018
pyo3/src/objects/mod.rs
Line 183 in 9dc7661
The macro
pyobject_extract!usesTryFrom. To use PyO3 in stable rust, this library itself must be compiled with stable rustc.IMHO, there is no merit to use this unstable feature, and should be dropped.
Feature gate try_from
konstin commentedon May 5, 2018
@termoshtt Good catch! pyo3 implements TryFrom, even though it currently uses PyTryFrom instead. I put a feature gate onto the implementation of TryFrom and removed the try_from feature. Once TryFrom becomes stable, we can than replace PyTryFrom.
termoshtt commentedon May 13, 2018
Drop of
fn_must_usein afcc87e causes many warnings13 remaining items
davidhewitt commentedon Apr 22, 2020
Progress slowly continues; we want to get there but need more volunteer time to get this over the finish line yet. (pyo3 maintainer time in the last few months has been spent mostly on soundness problems as well as bugfixes, which are also very important.)
Last items to resolve are in #697. I can offer mentoring advice to anyone interested in helping out with pieces of the solution in there.
TheButlah commentedon Apr 23, 2020
@jcdyer The emphasis is on easy interoperability, not just any interoperability, which is the purpose of PyO3. That being said, I did pitch rust to my coworkers, and got enough leeway to experiment with it in a side project - because I realized that nightly wasn't as bad as it sounded.
That being said, I work in a research lab not an enterprise company and our risk tolerance for these sorts of things is significantly higher, so continuing to focus on using stable would be a big selling point for the language overall. Glad to see how active this community is - it says a lot about the language and ecosystem :)
kngwyu commentedon Apr 24, 2020
Yeah, I also think it's a matter of time.
Now I have a serious NeurIPS deadline. Please wait for a bit.
nacaclanga commentedon Apr 29, 2020
Hello. It appears to me, from reading #210, that specialisisation is mostly used to implement class declaration. So how hard would it be to introducing a feature
no-unstable-class-supportto pyo3 that simply switches off class declaration, but allows code to be compiled on stable rust? People that want to use pyo3 instead of rust-cpython and can live without classes could then do so without having to use unstable.Once specialisation is stable or pyo3 managed to get rid of it, class declaration would be allowed in
no-unstable-class-supportand the feature would become identical to the default configuration again. I think this would also be very much in line on how rustc itself adds new features.An alternative would be the other way around: Make
no-unstable-class-supportthe default and introduce a featureallow-unstable-class-support.programmerjake commentedon Apr 29, 2020
if we're going to use a cargo feature, we should use the enable unstable code feature rather than the disable version, since cargo features should be additive since that's how cargo's designed.
as an example, if one crate uses the unstable code and another one doesn't, then using the enable version of the feature would correctly deduce that unstable code should be enabled for the crate that requires it. if it was the disable version then cargo would incorrectly disable the unstable code even though a crate requires it, leading to compile failure.
If anything requires unstable code, then you need to use the unstable compiler on all the crates anyway in order to have the compiler versions match, so that's not a limitation.
nacaclanga commentedon Apr 29, 2020
Make sense. The reason I thought it up the other way round is, that it might make things appear from the documentation, but one should be able to work around this.
philmb3487 commentedon May 15, 2020
Hi. I don't know a lot about Rust, but trying to run an application I use often that recently introduced bits of rust.
Why can't PyO3 work with Rust 1.43.1, released last week? My OS ships stable rust. This ticket is 3 years old now, this is annoying.
davidhewitt commentedon May 15, 2020
Read comments above, work is ongoing to fix this but it takes time...
jcdyer commentedon May 15, 2020
@sinetek The answer to the question you asked is in the thread above.
If you would like to get it working, the recommended way to work with rust as a developer is to use rustup to manage your rust toolchains, so you can have nightly and stable running side by side. You can get rustup from https://rustup.rs.
Then run the following:
Then when you want do run on stable, you can switch back with
rustup default stable. You can also set per-directory overrides withrustup override. Runrustup override --helpfor details.You can find more detail here: https://github.com/rust-lang/rustup#working-with-nightly-rust
davidhewitt commentedon Jun 21, 2020
For all those following this thread... the current PyO3 master branch just had a PR merged which added support for stable Rust.
Extra special thanks to @kngwyu and @konstin who have been working to remove specialization from PyO3 for a long time - and as of this morning, we finally got there! 🎉 🚀 🐍 🦀
ikamensh commentedon Jun 21, 2020
gilescope commentedon Jun 22, 2020
That's awesome progress you've been making this past 6 months! Huge congratulations on all your efforts.
TheButlah commentedon Jun 22, 2020
excitement intensifies
fafhrd91 commentedon Jun 22, 2020
congrats!