code.putln("{")
code.putln("PyObject *modules = PyImport_GetModuleDict(); %s" %
code.error_goto_if_null("modules", self.pos))
- code.putln('if (!PyDict_GetItemString(modules, "%s")) {' % env.module_name)
+ code.putln('if (!PyDict_GetItemString(modules, "%s")) {' % env.qualified_name)
code.putln(code.error_goto_if_neg('PyDict_SetItemString(modules, "%s", %s)' % (
- env.module_name, env.module_cname), self.pos))
+ env.qualified_name, env.module_cname), self.pos))
code.putln("}")
code.putln("}")
code.putln("#endif")
--- /dev/null
+PYTHON setup.py build_ext --inplace
+PYTHON -c "import a"
+
+######## setup.py ########
+
+from Cython.Build.Dependencies import cythonize
+import Cython.Compiler.Options
+Cython.Compiler.Options.cimport_from_pyx = True
+
+from distutils.core import setup
+
+setup(
+ ext_modules = cythonize("**/*.pyx"),
+ )
+
+######## a.pyx ########
+
+import sys
+import a
+assert a in sys.modules.values(), list(sys.modules)
+assert sys.modules['a'] is a, list(sys.modules)
+
+from atest.package import module
+
+######## atest/__init__.py ########
+
+######## atest/package/__init__.py ########
+
+######## atest/package/module.pyx ########
+
+import sys
+assert 'atest.package.module' in sys.modules
+
+import a
+import atest.package.module as module
+assert module in sys.modules.values(), list(sys.modules)
+assert sys.modules['atest.package.module'] is module, list(sys.modules)