Skip to content

Commit

Permalink
msvc: Fix default MICROPYPATH
Browse files Browse the repository at this point in the history
Default windows installations do not use HOME but USERPROFILE as the environment
variable for the user's home directory. Also there is no notion of a common
directory like /usr/lib so exclude it from the default path.
  • Loading branch information
stinos committed May 27, 2015
1 parent c754d80 commit b4602ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions py/mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,9 @@ typedef double mp_float_t;
#define MP_UNLIKELY(x) __builtin_expect((x), 0)
#endif

// Environment variable to fetch for user's home directory
#ifndef MP_ENVVAR_HOME
#define MP_ENVVAR_HOME "HOME"
#endif

#endif // __MICROPY_INCLUDED_PY_MPCONFIG_H__
6 changes: 5 additions & 1 deletion unix/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,14 @@ int main(int argc, char **argv) {
MP_STATE_VM(keyboard_interrupt_obj) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
#endif

char *home = getenv("HOME");
char *home = getenv(MP_ENVVAR_HOME);
char *path = getenv("MICROPYPATH");
if (path == NULL) {
#ifndef _MSC_VER
path = "~/.micropython/lib:/usr/lib/micropython";
#else
path = "~/.micropython/lib";
#endif
}
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)) {
Expand Down
2 changes: 1 addition & 1 deletion windows/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void msec_sleep(double msec);
#else
#define MP_SSIZE_MAX _I32_MAX
#endif

#define MP_ENVVAR_HOME "USERPROFILE"

// CL specific definitions

Expand Down

0 comments on commit b4602ee

Please sign in to comment.