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
--- a/tests/build/cythonize_pep420_namespace.srctree+++ b/tests/build/cythonize_pep420_namespace.srctree@@ -31,9 +31,17 @@ cdef class A:
######## nsp/m2/b.pyx ########
+from nsp.m1 cimport a
from nsp.m1.a cimport A
+from nsp.m3.c cimport d ### BROKEN
from nsp.m3.c.d cimport D
+cimport nsp.m1+cimport nsp.m1.a+cimport nsp.m3+cimport nsp.m3.c ### BROKEN+cimport nsp.m3.c.d+
cdef class B(A):
pass
I added several new tests for the different ways one can cimport modules. All of them work ok, except the two I've marked BROKEN which corresponds to the ones mentioned in the description.
Build and run ./runtests.py cythonize_pep420_namespace, to get:
Error compiling Cython file:
------------------------------------------------------------
...
from nsp.m1 cimport a
from nsp.m1.a cimport A
from nsp.m3.c cimport d
^
------------------------------------------------------------
nsp/m2/b.pyx:4:0: 'nsp/m3/c.pxd' not found
Comment out the first line marked BROKEN above and repeat the test to get:
Error compiling Cython file:
------------------------------------------------------------
...
from nsp.m3.c.d cimport D
cimport nsp.m1
cimport nsp.m1.a
cimport nsp.m3
cimport nsp.m3.c
^
------------------------------------------------------------
nsp/m2/b.pyx:10:8: 'nsp/m3/c.pxd' not found
Comment out the second line marked BROKEN, now all tests pass.
Describe the bug
When
PACKAGE
is a namespace package, then both:or
from PACKAGE cimport MODULE
fail at compilation, complaining that
PACKAGE.pxd
can't be found.Presumably cython has looked for
PACKAGE/__init__.*
andPACKAGE.*
which are not available for a namespace package.This was discovered as part of sagemath/sage#35322.
Code to reproduce the behaviour:
I added several new tests for the different ways one can
cimport
modules. All of them work ok, except the two I've marked BROKEN which corresponds to the ones mentioned in the description../runtests.py cythonize_pep420_namespace
, to get:Expected behaviour
All tests pass, including the two marked BROKEN.
OS
linux
Python version
3.11.2
Cython version
3.0.0b1+master (2ea4f96)
Additional context
In sagemath we still use 0.29.33, with #2946 backported (see https://github.com/sagemath/sage/blob/develop/build/pkgs/cython/patches/4918.patch) so other uses of namespace packages work ok.
Whatever is the solution, it'd be nice to have it backported to 0.29.x.
It would also be wonderful if 0.29.34 could include #2946.
The text was updated successfully, but these errors were encountered: