mattytrentini / mpbuild

MicroPython build tool
MIT License
17 stars 5 forks source link

Allow mpbuild to run when pwd is not the root of a MicroPython clone #26

Open hmaerki opened 2 months ago

hmaerki commented 2 months ago

Bug

mpbuild/src/mpbuild/__init__.py

try:
    os.stat("./ports")
except OSError:
    raise SystemExit("Please run from root of micropython source tree")

When I import pyboard in octoprobe, I get above exception.

Proposed fix

Do not throw the exception while importing the module. Throw the exception in the command line module.

Pass the root of micropython source tree to build.build_board() and other some functions.

This will allow to use mpbuild without the need to cd.

Josverl commented 2 months ago

I think an exception is fine, but perhaps not a SystemExit.

hmaerki commented 2 months ago

I think an exception is fine, but perhaps not a SystemExit. This implies, that mpbuild may not be used as a python package (just as external program)...

Again: I can not see any reason why to do do an assertion on the current directory while module loading.

Do you want me to create a PR which fixes this?

mattytrentini commented 2 months ago

This has been partially resolved with #28 but I want to take it a little further before closing this issue.