wendlers / mpfshell

A simple shell based file explorer for ESP8266 Micropython based devices ⛺
MIT License
396 stars 84 forks source link

mpyc not documented #15

Closed mkarliner closed 8 years ago

mkarliner commented 8 years ago

What does it do?

:-)

Mike

drawkula commented 8 years ago

mpyc is defined in mp/mpfshell.py lines 597...621.

mpfs [/]> help mpyc                                                                                   
mpyc <LOCAL PYTHON FILE>                                                                              
        Compile a Python file into byte-code by using mpy-cross (which needs to be in the path).      
        The compiled file has the same name as the original file but with extension '.mpy'.           

mpfs [/]> _

Some ports of MicroPython allow loading and execution of those precompiled files from the file system.

mpy-cross is part of the MicroPython source tree.


Relevant too: http://forum.micropython.org/viewtopic.php?f=3&t=2334&p=13327


I've built and flashed MicroPython without the mentioned changes to one my NodeMCU Devkit clones and it does not load .mpy files from the file system.

A second clone has got the same MicroPython version with those changes added:

mpfs [/]> lls

Local files:

       port_config.py
       boot.py
       HelloPython.mpy
       HelloPython.py

mpfs [/]> put HelloPython.mpy
mpfs [/]> repl
>
*** Exit REPL with Ctrl+] ***

MicroPython v1.8.3-127-ge1e1014 on 2016-09-08; ESP module with ESP8266
Type "help()" for more information.
>>> import HelloPython
Hello, Python!
>>> os.listdir()
['boot.py', 'HelloPython.mpy']
>>> _

...there is no HelloPython.py so it must have executed HelloPython.mpy.

HelloPython.py is this oneliner:

print("Hello, Python!")

Ok... so this still is not a feature in all ports by default.

mkarliner commented 8 years ago

Thanks.