0

The title almost explains everything.

I'm trying to cimport a module with

cimport myMinExPkg.someModule.base as someModuleBase

and then using the "someModuleBase" alias like

someModuleBase.BaseClass

but this results in an error

myMinExPkg/someModule/baseExt.pxd:7:5: 'someModuleBase.pxd' not found

I don't know why Cython is looking for this pxd file. If I rename the alias to the same name as the file it works, e.g.

cimport myMinExPkg.someModule.base as base

or just

cimport myMinExPkg.someModule.base

and using them appropiately. But that is of course not the point, it should work either way in my opinion. I tried searching SO and google, but only found solutions to obvious mistakes I don't think I'm making.

--------------------------------------------------------------------------

Additional information:

My folder structure looks something like this

├── myMinExPkg
│   ├── __init__.py
│   └── someModule
│       ├── base.c
│       ├── baseExt.c
│       ├── baseExt.pxd
│       ├── baseExt.pyx
│       ├── base.pxd
│       ├── base.pyx
│       ├── __init__.py
├── setup.py

setup.py file

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize

ecadef = ["-O1", "-Wunused-but-set-variable"]
iddef = ["/usr/local/include/", "./myMinExPkg","/usr/local/lib/"]


extensions = cythonize([
                        Extension('myMinExPkg.someModule.base',
                            sources=['myMinExPkg/someModule/base.pyx'],
                            extra_compile_args = ecadef,
                            include_dirs = iddef
                            ),
                        Extension('myMinExPkg.someModule.baseExt',
                            sources=['myMinExPkg/someModule/baseExt.pyx'],
                            extra_compile_args = ecadef,
                            include_dirs = iddef
                            )
                        ])


setup(name = 'myMinExPkg',
      packages = ['myMinExPkg', 'myMinExPkg.someModule'],
      package_data={'myMinExPkg': ['*.pxd'], 
                    'myMinExPkg.someModule': ['*.pxd']},
      cmdclass = {'build_ext': build_ext},
      ext_modules = extensions
     )
oli
  • 659
  • 1
  • 6
  • 18

0 Answers0