diff --git a/cython_multibuild/multibuild.py b/cython_multibuild/multibuild.py index 1d08de84e2c991e111fcc154d58fc9d6475d47b6..fd9557c803ea4188eac070ac8239754bf71eab11 100644 --- a/cython_multibuild/multibuild.py +++ b/cython_multibuild/multibuild.py @@ -44,7 +44,7 @@ class Multibuild: with open(os.path.join(path, h_name), 'w') as f_out: f_out.write(data) else: - with open(os.path.join(path, name.replace('.pyx', '.h')), 'w') as f_out: + with open(os.path.join(path, h_name), 'w') as f_out: f_out.write('#include "Python.h"\n') f_out.write('\n'+exported_line+'\n') @@ -64,7 +64,7 @@ cdef extern from "Python.h": path = path.replace(self.bootstrap_directory, '') module_name = name.replace('.pyx', '') if path: - h_path_name = os.path.join(path, name.replace('.pyx', '.h')) + h_path_name = os.path.join(path[1:], name.replace('.pyx', '.h')).replace('\\', '\\\\') else: h_path_name = name.replace('.pyx', '.h') bootstrap_contents.append('cdef extern from "%s":\n' % (h_path_name, )) @@ -72,7 +72,12 @@ cdef extern from "Python.h": module_py_name = '.'.join([self.extension_name] + h_path_name.split(os.path.sep)) - self.modules.add((self.extension_name+'.'+module_name, 'PyInit_%s()' % (module_name, ))) + if path: + complete_module_name = self.extension_name+'.'+'.'.join(path[1:].split(os.path.sep))+'.'+module_name + else: + complete_module_name = self.extension_name + '.'+module_name + + self.modules.add((complete_module_name, 'PyInit_%s()' % (module_name, ))) bootstrap_contents.append('''cdef object get_definition_by_name(str name):\n''') modules = iter(self.modules) diff --git a/example/example_module/__init__.py b/example/example_module/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a29ecf4eaf1abe9780e953bc0c7c7508965cd3c9 100644 --- a/example/example_module/__init__.py +++ b/example/example_module/__init__.py @@ -0,0 +1,3 @@ + +from example_module.__bootstrap__ import bootstrap_cython_submodules +bootstrap_cython_submodules()