-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Python] Building with Cython 3 shows warnings #34564
Comments
Right, my understanding is that Cython doesn't really know about rvalue references or move semantics. To generate correct C++ code involving functions that accept rvalue references, you can declare them as accepting type # distutils: language=c++
# extra_compile_args: -std=c++17
from libcpp.utility cimport move
cdef extern from *:
"""
class Foo {
public:
Foo() = default;
};
void bar(Foo&& x) {
return;
}
"""
cppclass Foo:
Foo()
void bar(Foo) # no need to declare this void bar(Foo&&)
cdef Foo f = Foo()
# bar(f) -> compile error
bar(move(f)) # works |
Ok, removing the rvalue's in that way sounds reasonable. How do we regress this? Ideally we could get some kind of cython 3 build in our CI. How close is cython 3 to releasing? |
I don’t have a good sense of the timeline, but Cython 3 is now “beta” status. For now, I would propose fixing the warnings as a one-time pass. Then later when Cython 3 is released, use it in CI with warnings as errors. What do you think? |
That seems fine but a number of people contribute to the cython bindings (and not all of them are reading this issue) so I think there is a reasonable chance that warnings will creep back in. |
I was thinking about opening this issue because I saw a bunch of references to arrow in cython/cython#5305. It's possible that some have been fixed on
Based on the progress so far (and some new blockers arising as people start testing beta1 in earnest), I'm guessing it'll still take several weeks to have beta2, much less the final release. |
I think it's fine to already start fixing some of those cases without CI, while also look at adding CI support eventually (I don't think that should be difficult, we can install the In the meantime, should we actually pin cython to <3 in our "requires" table in pyproject.toml? |
I started trying to fix these but ran into some problems that I think are bugs in cython? This one is a warning (the method
This one is an error (the method
And then this code:
at some point unwraps into:
However, the
Since
Is there somewhere I should file these against the cython project or are they already known issues? |
A bunch of them are known, see. e.g. cython/cython#5305 (e.g. the |
I filed an issue for the |
### Rationale for this change Cython 3 has some breaking changes: * `&&` is no longer supported * `nogil` must appear at the end of the line In addition we had to work around a bug: cython/cython#5333 ### What changes are included in this PR? Minor changes to the cython code. ### Are these changes tested? No, and they probably should be at some point. However, Cython 3 has not yet released and so it would be impractical to update our CI to run Cython 3 until that happens. ### Are there any user-facing changes? No * Closes: #34564 Authored-by: Weston Pace <weston.pace@gmail.com> Signed-off-by: Weston Pace <weston.pace@gmail.com>
…pache#34726) ### Rationale for this change Cython 3 has some breaking changes: * `&&` is no longer supported * `nogil` must appear at the end of the line In addition we had to work around a bug: cython/cython#5333 ### What changes are included in this PR? Minor changes to the cython code. ### Are these changes tested? No, and they probably should be at some point. However, Cython 3 has not yet released and so it would be impractical to update our CI to run Cython 3 until that happens. ### Are there any user-facing changes? No * Closes: apache#34564 Authored-by: Weston Pace <weston.pace@gmail.com> Signed-off-by: Weston Pace <weston.pace@gmail.com>
Thanks Weston! I opened #34756 for adding a build with Cython 3 to our CI |
…pache#34726) ### Rationale for this change Cython 3 has some breaking changes: * `&&` is no longer supported * `nogil` must appear at the end of the line In addition we had to work around a bug: cython/cython#5333 ### What changes are included in this PR? Minor changes to the cython code. ### Are these changes tested? No, and they probably should be at some point. However, Cython 3 has not yet released and so it would be impractical to update our CI to run Cython 3 until that happens. ### Are there any user-facing changes? No * Closes: apache#34564 Authored-by: Weston Pace <weston.pace@gmail.com> Signed-off-by: Weston Pace <weston.pace@gmail.com>
This PR contains the minimal set of changes to compile using Cython 3 without warnings. Future PRs can be made to take advantage of new or improved features. The specific changes are: - Ensuring `nogil` always comes after `except`. `except * nogil` is a compile-time error in Cython 3 - Removing any extern cdef functions that uses C++ rvalues. These were never supported by Cython, but prior to 3.0 they were silently ignored whereas now Cython throws warnings during compilation - Relative imports are no longer off by one level in pxd files and must be adjusted accordingly (see cython/cython#3442) There are a large number of outstanding warnings due to NVIDIA/cuda-python#44. cuda-python for CUDA 12 has the necessary fix, but we will need a cuda-python 11.8.* bugfix with a backport to make those warnings go away. There are also warnings coming from pyarrow due to apache/arrow#34564. pyarrow 12 contains the necessary fixes, so this issues should be resolved once #13728 is merged. Authors: - Vyas Ramasubramani (https://github.com/vyasr) - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Ray Douglass (https://github.com/raydouglass) - Bradley Dice (https://github.com/bdice) - Benjamin Zaitlen (https://github.com/quasiben) - GALI PREM SAGAR (https://github.com/galipremsagar) - https://github.com/jakirkham URL: #13777
Describe the enhancement requested
When building against PyArrow's Cython interface with Cython 3.0.0 beta 1, I see the following warnings:
For the
nogil
warning, I think the fix is straightforward - just move thenogil
qualifier to the end of the line.For the Rvalue-reference warnings, I discussed some similar warnings with @shwina, who initially contributed the PR that added these warnings. He said the best fix is to remove definitions with Rvalue references (
T&&
) as arguments, because Cython can't use them anyway.Let me know if a PR to fix these warnings would be helpful.
Component(s)
Python
The text was updated successfully, but these errors were encountered: