> Date: Thu, 02 Feb 2012 08:11:16 +0100 > From: Stefan Behnel <stefan...@behnel.de> > To: Core developer mailing list of the Cython compiler > <cython-devel@python.org> > Subject: Re: [Cython] distutils extension pxd problem > Message-ID: <4f2a3714.7000...@behnel.de> > Content-Type: text/plain; charset=UTF-8 > > Dimitri Tcaciuc, 02.02.2012 01:53: >> I bumped into an issue where my .pyx file doesn't see its matching >> .pxd file. Here's a build test to show the problem If I change my >> target package from `b.a` to just `a`, it works as expected. Running >> `cython src/a.pyx` works as expected as well, but not the Extension. >> >> ---- >> >> PYTHON setup.py build_ext --inplace >> PYTHON -c "from b import a" >> >> ######## setup.py ######## >> >> from distutils.core import setup >> from distutils.extension import Extension >> from Cython.Distutils import build_ext >> >> ext_modules = [ >> Extension("b.a", ["src/a.pyx"]) >> ] >> >> setup( >> cmdclass = {'build_ext': build_ext}, >> ext_modules = ext_modules >> ) >> >> ######## b/__init__.py ######## >> >> ######## src/a.pxd ######## >> >> cdef class X: >> cdef object foo >> >> ######## src/a.pyx ######## >> >> cdef class X: >> >> def __cinit__(self): >> self.foo = 1 >> >> x = X() >> >> ---- >> >> Traceback (most recent call last): >> File "<string>", line 1, in <module> >> File "a.pyx", line 7, in init b.a (src/a.c:793) >> File "a.pyx", line 5, in b.a.X.__cinit__ (src/a.c:488) >> AttributeError: 'b.a.X' object has no attribute 'foo' >> >> ---- > > Any reason you cannot rename "src" to "b"? Because that would fix your > problem. Cython basically uses the same algorithm for finding package > content as Python, i.e. it will look inside the package "b" when looking > for "b.a". And "a.pxd" is not in "b" in your setup. > > Stefan >
This certainly looks like the cleanest solution now. I have some mixed C++ bits in src/ so I thought to keep compiled/interpreted bits separate, if possible. Dimitri. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel