Permalink
Browse files

Remove Modules/getpath.c from OVM.

I had to stub out sys.executable because 'import platform' uses it.

Tested with:

    scripts/release.sh oil
    build/test.sh oil-tar
    build/metrics.sh linecount-nativedeps
  • Loading branch information...
Andy Chu
Andy Chu committed May 18, 2018
1 parent 33e867f commit 035d59888bd284407ce6a8e6ff99bb3fa3997432
Showing with 22 additions and 10 deletions.
  1. +11 −2 Python-2.7.13/Python/pythonrun.c
  2. +11 −0 Python-2.7.13/Python/sysmodule.c
  3. +0 −8 build/compile.sh
@@ -248,8 +248,13 @@ Py_InitializeEx(int install_sigs, char* sys_path)
Py_FatalError("Py_Initialize: can't initialize sys dict");
Py_INCREF(interp->sysdict);
_PyImport_FixupExtension("sys", "sys");
if (sys_path == NULL)
if (sys_path == NULL) {
#ifdef OVM_MAIN
Py_FatalError("Py_Initialize: expected sys_path to be set");
#else
sys_path = Py_GetPath();
#endif
}
PySys_SetPath(sys_path);
PyDict_SetItemString(interp->sysdict, "modules",
@@ -619,8 +624,12 @@ Py_NewInterpreter(void)
if (interp->sysdict == NULL)
goto handle_error;
Py_INCREF(interp->sysdict);
fprintf(stderr, "OVM warning: got to a line that calls Py_GetPath()\n");
#ifdef OVM_MAIN
fprintf(stderr, "OVM: Can't call Py_GetPath()\n");
assert(0);
#else
PySys_SetPath(Py_GetPath());
#endif
PyDict_SetItemString(interp->sysdict, "modules",
interp->modules);
_PyImportHooks_Init();
@@ -1441,12 +1441,23 @@ _PySys_Init(void)
PyString_FromString(Py_GetCopyright()));
SET_SYS_FROM_STRING("platform",
PyString_FromString(Py_GetPlatform()));
/* getpath.c was removed */
#ifdef OVM_MAIN
/* 'import platform' uses sys.executable for a default arg to libc_ver().
* Stub it out with a dummy. */
SET_SYS_FROM_STRING("executable",
PyString_FromString("OVM_DUMMY_STRING"));
#else
SET_SYS_FROM_STRING("executable",
PyString_FromString(Py_GetProgramFullPath()));
#endif
#ifndef OVM_MAIN
SET_SYS_FROM_STRING("prefix",
PyString_FromString(Py_GetPrefix()));
SET_SYS_FROM_STRING("exec_prefix",
PyString_FromString(Py_GetExecPrefix()));
#endif
SET_SYS_FROM_STRING("maxsize",
PyInt_FromSsize_t(PY_SSIZE_T_MAX));
SET_SYS_FROM_STRING("maxint",
View
@@ -9,13 +9,6 @@ set -o errexit
source build/common.sh
# TODO:
# - Can probably delete frozen*.c. It might be more efficient in theory, but
# it's not the bottleneck. It's less debuggable uses the fairly complex
# Tools/freeze.py and modulefinder module. Have to remove hooks in import.c.
# - getpath.c can be removed. Has hooks in sys.exec_prefix, etc. which we
# don't need.
readonly OVM_PYTHON_OBJS='
Python/_warnings.c
Python/bltinmodule.c
@@ -95,7 +88,6 @@ Objects/unicodectype.c
# Non-standard lib stuff.
MODULE_OBJS='
Modules/getpath.c
Modules/main.c
Modules/gcmodule.c
'

0 comments on commit 035d598

Please sign in to comment.