[SOLVED] How to include modules in 'unix' build of micropython?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jpj
Posts: 60
Joined: Sat Dec 10, 2016 3:07 pm

[SOLVED] How to include modules in 'unix' build of micropython?

Post by jpj » Mon Dec 26, 2016 3:22 am

I installed the vagrant build environment to include modules like sdcard in my firmware using this guide. It works great!
https://learn.adafruit.com/building-and ... d-firmware

This is the Adafruit fork of micropython on GitHub. It includes the 'unix' directory where you can build an executable version of micropython to run and test with right inside of the VM.

How can I include modules like 'time' in this build? I didn't see a 'modules' subfolder. I'm happy to read a doc if there is one available.

Thanks,
J

Code: Select all

vagrant@vagrant-ubuntu-trusty-64:~/micropython$ cd unix/
vagrant@vagrant-ubuntu-trusty-64:~/micropython/unix$ ls
alloc.c       fdfile.h     micropython      modtermios.c             mpconfigport_minimal.h  scripts
array.py      file.c       micropython.map  modtime.c                mpconfigport.mk         unix_mphal.c
build         gccollect.c  modffi.c         moduselect.c             mpconfigport_nanbox.h
callfunc.py   input.c      modjni.c         mpconfigport_coverage.h  mphalport.h
classes.py    input.h      modmachine.c     mpconfigport_fast.h      mpthreadport.c
coverage.c    main.c       modos.c          mpconfigport_freedos.h   mpthreadport.h
fatfs_port.c  Makefile     modsocket.c      mpconfigport.h           qstrdefsport.h

vagrant@vagrant-ubuntu-trusty-64:~/micropython/unix$ ./micropython
MicroPython v1.8.6-234-gefa206d on 2016-12-22; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import time
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'time'
Last edited by jpj on Mon Dec 26, 2016 12:57 pm, edited 1 time in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to include modules in 'unix' build of micropython?

Post by pythoncoder » Mon Dec 26, 2016 7:10 am

Peter Hinch
Index to my micropython libraries.

jpj
Posts: 60
Joined: Sat Dec 10, 2016 3:07 pm

Re: How to include modules in 'unix' build of micropython?

Post by jpj » Mon Dec 26, 2016 12:56 pm

That's precisely what I needed.

Thank you!

Post Reply