--- contrib/tools/cython_py2/Cython/Compiler/Main.py (index) +++ contrib/tools/cython_py2/Cython/Compiler/Main.py (working tree) @@ -701,48 +701,27 @@ def search_include_directories(dirs, qualified_name, suffix="", pos=None, includ if suffix: dotted_filename += suffix - for dirname in dirs: - path = os.path.join(dirname, dotted_filename) - if os.path.exists(path): - return path - - # search for filename in package structure e.g. /foo/bar.pxd or /foo/bar/__init__.pxd if not include: - names = qualified_name.split('.') package_names = tuple(names[:-1]) module_name = names[-1] + module_filename = module_name + suffix + package_filename = "__init__" + suffix - # search for standard packages first - PEP420 - namespace_dirs = [] - for dirname in dirs: - package_dir, is_namespace = Utils.check_package_dir(dirname, package_names) - if package_dir is not None: - if is_namespace: - namespace_dirs.append(package_dir) - continue - path = search_module_in_dir(package_dir, module_name, suffix) - if path: - return path - - # search for namespaces second - PEP420 - for package_dir in namespace_dirs: - path = search_module_in_dir(package_dir, module_name, suffix) - if path: - return path + for dirname in dirs: + path = os.path.join(dirname, dotted_filename) + if os.path.exists(path): + return path # Arcadia-specific lookup: search for packages in include paths, # ignoring existence of __init__.py files as packages markers # (they are not required by Arcadia build system) - module_filename = module_name + suffix - package_filename = "__init__" + suffix - - for dir in dirs: - package_dir = os.path.join(dir, *package_names) + if not include: + package_dir = os.path.join(dirname, *package_names) path = os.path.join(package_dir, module_filename) if os.path.exists(path): return path - path = os.path.join(dir, package_dir, module_name, + path = os.path.join(dirname, package_dir, module_name, package_filename) if os.path.exists(path): return path --- contrib/tools/cython_py2/Cython/Compiler/Nodes.py (index) +++ contrib/tools/cython_py2/Cython/Compiler/Nodes.py (working tree) @@ -8944,7 +8944,7 @@ class FromCImportStatNode(StatNode): # 2. case: importing from same level but current dir is not package: from . import module error(self.pos, "relative cimport from non-package directory is not allowed") return - module_scope = env.find_module(self.module_name, self.pos, relative_level=self.relative_level) + module_scope = env.find_module(self.module_name, self.pos, relative_level=self.relative_level, need_pxd=0) if not module_scope: return module_name = module_scope.qualified_name --- contrib/tools/cython_py2/Cython/Compiler/Symtab.py (index) +++ contrib/tools/cython_py2/Cython/Compiler/Symtab.py (working tree) @@ -1411,7 +1411,7 @@ class ModuleScope(Scope): entry.qualified_name = self.builtin_scope().qualify_name(name) return entry - def find_module(self, module_name, pos, relative_level=-1): + def find_module(self, module_name, pos, relative_level=-1, need_pxd=1): # Find a module in the import namespace, interpreting # relative imports relative to this module's parent. # Finds and parses the module's .pxd file if the module @@ -1440,7 +1440,7 @@ class ModuleScope(Scope): module_scope = self.global_scope() return module_scope.context.find_module( - module_name, from_module=from_module, pos=pos, absolute_fallback=absolute_fallback, relative_import=is_relative_import) + module_name, from_module=from_module, pos=pos, absolute_fallback=absolute_fallback, relative_import=is_relative_import, need_pxd=need_pxd) def find_submodule(self, name, as_package=False): # Find and return scope for a submodule of this module,