Skip to content

Commit 712a703

Browse files
committed
When calculating the base for an import, be sure to include that module's package.
1 parent 1c6a14b commit 712a703

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

discovery.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,22 @@ def is_python(path: pathlib.Path) -> bool:
149149
return path.suffix == '.py'
150150

151151

152+
def base(module):
153+
"""
154+
>>> base(pathlib.Path('foo/bar/bin.py'))
155+
'coherent.build.foo.bar'
156+
>>> base(pathlib.Path('foo.py'))
157+
'coherent.build'
158+
"""
159+
return '.'.join((best_name(),) + module.parent.parts)
160+
161+
152162
def inferred_deps():
153163
"""
154164
Infer deps from module imports.
155165
"""
156166
names = [
157-
(imp.relative_to(best_name()), module)
167+
(imp.relative_to(base(module)), module)
158168
for module in filter(is_python, source_files())
159169
for imp in imports.get_module_imports(module)
160170
if not imp.standard()

0 commit comments

Comments
 (0)