Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pybricksdev/compile.py: Add better error message #85

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Use relative paths when compiling multi-file projects.
- Better error message when hitting Python bug when compiling multi-file projects.

## [1.0.0-alpha.48] - 2024-05-04

Expand Down
8 changes: 7 additions & 1 deletion pybricksdev/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ async def compile_multi_file(path: str, abi: Union[int, Tuple[int, int]]):
# compile files using Python to find imports contained within the same directory as path
search_path = [os.path.dirname(path)]
finder = ModuleFinder(search_path)
finder.run_script(path)

try:
finder.run_script(path)
except AttributeError as e:
raise RuntimeError(
"ModuleFinder doesn't currently handle implicit namespace packages. Did you forget to put an __init__.py file in one of your subdirectories? See https://github.com/pybricks/support/issues/1602"
) from e

# we expect missing modules, namely builtin MicroPython packages like pybricks.*
logger.debug("missing modules: %r", finder.any_missing())
Expand Down
Loading