Skip to content

Commit 517e170

Browse files
committed
Merge pull request adafruit#309 from pfalcon/stm-sys-path
stm: Initialize sys.path with ["0:/", "0:/src", "0:/lib"].
2 parents ff77dc5 + 4aee119 commit 517e170

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

py/makeqstrdata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
# add some custom names to map characters that aren't in HTML
1212
codepoint2name[ord('.')] = 'dot'
13+
codepoint2name[ord(':')] = 'colon'
14+
codepoint2name[ord('/')] = 'slash'
1315

1416
# this must match the equivalent function in qstr.c
1517
def compute_hash(qstr):

stm/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ int main(void) {
367367
// Micro Python init
368368
qstr_init();
369369
rt_init();
370+
mp_obj_t def_path[3];
371+
def_path[0] = MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_);
372+
def_path[1] = MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_src);
373+
def_path[2] = MP_OBJ_NEW_QSTR(MP_QSTR_0_colon__slash_lib);
374+
sys_path = mp_obj_new_list(3, def_path);
370375

371376
#if MICROPY_HW_HAS_LCD
372377
// LCD init (just creates class, init hardware by calling LCD())

stm/qstrdefsport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ Q(Usart)
3232
Q(ADC)
3333
Q(open)
3434
Q(File)
35+
// Entries for sys.path
36+
Q(0:/)
37+
Q(0:/src)
38+
Q(0:/lib)

0 commit comments

Comments
 (0)