unix: Allow to override default sys.path value.
Using MICROPY_PY_SYS_PATH_DEFAULT macro define. A usecase is building a distribution package, which should not have user home path by default in sys.path. In such case, MICROPY_PY_SYS_PATH_DEFAULT can be defined on make command-line (using CFLAGS_EXTRA).
This commit is contained in:
parent
c02dc8b2c9
commit
51726b4d43
@ -297,7 +297,11 @@ int main(int argc, char **argv) {
|
|||||||
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
||||||
char *path = getenv("MICROPYPATH");
|
char *path = getenv("MICROPYPATH");
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
|
#ifdef MICROPY_PY_SYS_PATH_DEFAULT
|
||||||
|
path = MICROPY_PY_SYS_PATH_DEFAULT;
|
||||||
|
#else
|
||||||
path = "~/.micropython/lib:/usr/lib/micropython";
|
path = "~/.micropython/lib:/usr/lib/micropython";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
mp_uint_t path_num = 1; // [0] is for current dir (or base dir of the script)
|
mp_uint_t path_num = 1; // [0] is for current dir (or base dir of the script)
|
||||||
for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) {
|
for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user