Hm, looks like I "cheered too soon" as we say.
I can execute the generated micropython.exe and run something like:
Code: Select all
MicroPython v1.13-70-g7c1511b1d-dirty on 2020-09-08 (fork); win32 version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import mypackage
>>> led = mypackage.MyClass()
>>>
However, if I create a script:
Code: Select all
# main.py
import mypackage
led = mypackage.MyClass()
And try to run this script:
I get:
Code: Select all
Traceback (most recent call last):
File ".\main.py", line 1, in <module>
ImportError: no module named 'mypackage'
Why this is happening is beyond me. The way commands are executed cannot be different from the way a script is, right?
Note that I am positive I am using the right executable.
EDIT: Hm, just noticed the same happens with the unix port on the official micropython branch: import on CLI is fine but fails from script. So not specific to my Windows port.
EDIT 2: It gets better. So I cannot run the script, but if I import the script as a module instead the new packages do work:
Code: Select all
PS C:\Users\name\source\repos\micropython\ports\windows> .\micropython.exe .\script.py
Traceback (most recent call last):
File ".\script.py", line 1, in <module>
ImportError: no module named 'mypackage'
PS C:\Users\name\source\repos\micropython\ports\windows> .\micropython.exe -m script
Hello world!