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
BUG: Build failure with Cython 3.0.0b3 if scipy is already installed #18792
Comments
Ugh yes, I need to follow up on that still. Relative imports in Cython are broken, and I'm fairly sure I figured out last time around that that is due to the recently-added depfile support (of course, there could be other reasons too). I'd expect this to be broken with Cython Thanks for the report @mgorny. |
Thanks for confirming that. FYI, it seems to build fine for me with 0.29.35. |
I'm a bit confused here. @mgorny reports that the error happens with Cython 3, where relative imports should be functional (modulo bugs, and this looks like one?). |
"functional modulo bugs" == broken (in this case) |
You recently added a test case to Cython to capture some of our setup. Is there a cython issue for the breakage we're encountering here? I'm pretty sure the Cython devs would be receptive for solving this. |
I don't think that there is any test case; it's quite tricky to set up a test for this since it's a failure mode that only shows up when there's a matching import in site-packages and that import has a mismatch with the local version of what one is importing. |
@scoder @da-woods @matusvalo |
Could you explain why there is both a cython_optimize.pxd file and a cython_optimize package? Why isn't the first in cython_optimize/__init__.pxd?
|
I suppose this is workaround for an issue from Cython 0.29.X. Suppose following file structure: ########## b/__init__.py ##########
########## b/__init__.pxd ##########
from .bb cimport ULong
########## b/bb.pxd ##########
ctypedef unsigned long ULong
########## a.pyx ##########
from .b cimport ULong
cdef ULong x = 10
print(x) In this file structure compiling I suppose (not 100% sure), scipy uses a workaround for using relative imports in packages is to use instead of ########## b/__init__.py ##########
########## b/bb.pxd ##########
ctypedef unsigned long ULong
########## b.pxd ##########
from .b.bb cimport ULong
########## a.pyx ##########
from .b cimport ULong
cdef ULong x = 10
print(x) Here compiling |
OK, I think I have fix. The issue seems to be in scipy build mechanism, not in Cython - see PR for details. |
Isn't it still a bug that a relative cimport ends up picking up a The build passes on all CI jobs if |
Yes I agree this is at least strange behaviour. I need to further investigate it. |
Closes gh-18792 [skip cirrus] [skip circle] --------- Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
Fixed for now in gh-18810, which should be backported to |
Closes scipygh-18792 [skip cirrus] [skip circle] --------- Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
Closes scipygh-18792 [skip cirrus] [skip circle] --------- Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
…earch globally (#5538) Previously, it could happen that a relative import from a local source copy found a module from a globally installed package instead, thus potentially mixing versions and leading to difficult to understand misbehaviour. Closes #5511 First reported in scipy/scipy#18792
Describe your issue.
When using Cython 3 to build scipy in an environment where it is installed already, it fails to build as pasted below. Judging from the error message, it seems to be using
cython_optimize.pxd
from the installed tree rather than the source directory and looking for_zeros.pxd
in path containing duplicatecython_optimize
component.The problem doesn't occur with Cython < 3, nor with Cython 3 if scipy is not yet installed.
This is causing problems when building the package for Gentoo. However, I was also able to reproduce it in pure venv, on top of git commit 9816141.
Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: