Skip to content

Commit

Permalink
When calculating the base for an import, be sure to include that modu…
Browse files Browse the repository at this point in the history
…le's package.
  • Loading branch information
jaraco committed Sep 6, 2024
1 parent 1c6a14b commit 712a703
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,22 @@ def is_python(path: pathlib.Path) -> bool:
return path.suffix == '.py'


def base(module):
"""
>>> base(pathlib.Path('foo/bar/bin.py'))
'coherent.build.foo.bar'
>>> base(pathlib.Path('foo.py'))
'coherent.build'
"""
return '.'.join((best_name(),) + module.parent.parts)


def inferred_deps():
"""
Infer deps from module imports.
"""
names = [
(imp.relative_to(best_name()), module)
(imp.relative_to(base(module)), module)
for module in filter(is_python, source_files())
for imp in imports.get_module_imports(module)
if not imp.standard()
Expand Down

0 comments on commit 712a703

Please sign in to comment.