I am a newbie to cython.
I've the following directory structure.
cython_program/ cython_program/helloworld.py cython_program/lib/printname.py helloworld.py:
import lib.printname as name def printname(): name.myname() printname.py:
def myname(): print("this is my name") setup.py:
from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [ Extension("helloworld", ["helloworld.py"]), Extension("mod", ["./lib/printname.py"]), ] setup( name = 'My Program', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules ) The problem I am having is that when I compile my program using python setup.py build_ext --inplace in the cython_program directory. It does compile the program successfully and generates a printname.c file in the lib folder.
But when I move the printname.py and helloworld.py to a separate folder to make sure that my cython compiled code is running. It gives me the following error ImportError: No module named lib.printname.
Why isn't it compiling the module(lib.printname) also with the main helloworld.py file ?
Note: This works fine if I keep both helloworld.py and printname.py in the same folder.
Thanks in advance.