235 lines
6.4 KiB
Diff
235 lines
6.4 KiB
Diff
diff -Naur Python-3.5.2-orig/configure.ac Python-3.5.2/configure.ac
|
|
--- Python-3.5.2-orig/configure.ac 2016-07-12 14:20:53.877300700 +0300
|
|
+++ Python-3.5.2/configure.ac 2016-07-12 14:20:54.264800700 +0300
|
|
@@ -5252,8 +5252,21 @@
|
|
;;
|
|
esac
|
|
|
|
+dnl getpath module - default sys.path calculations
|
|
+AC_SUBST(MODULE_GETPATH)
|
|
+MODULE_GETPATH=Modules/getpath.o
|
|
+case $host in
|
|
+ *-*-mingw*)
|
|
+ dnl default sys.path calculations for windows platforms
|
|
+ MODULE_GETPATH=PC/getpathp.o
|
|
+ ;;
|
|
+esac
|
|
+
|
|
AC_SUBST(SRCDIRS)
|
|
SRCDIRS="Parser Grammar Objects Python Modules Mac Programs"
|
|
+case $host in
|
|
+ *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
|
|
+esac
|
|
AC_MSG_CHECKING(for build directories)
|
|
for dir in $SRCDIRS; do
|
|
if test ! -d $dir; then
|
|
diff -Naur Python-3.5.2-orig/Makefile.pre.in Python-3.5.2/Makefile.pre.in
|
|
--- Python-3.5.2-orig/Makefile.pre.in 2016-06-26 00:38:37.000000000 +0300
|
|
+++ Python-3.5.2/Makefile.pre.in 2016-07-12 14:20:54.272800700 +0300
|
|
@@ -249,7 +249,7 @@
|
|
# Modules
|
|
MODULE_OBJS= \
|
|
Modules/config.o \
|
|
- Modules/getpath.o \
|
|
+ @MODULE_GETPATH@ \
|
|
Modules/main.o \
|
|
Modules/gcmodule.o
|
|
|
|
@@ -747,6 +747,7 @@
|
|
-DHGBRANCH="\"`LC_ALL=C $(HGBRANCH)`\"" \
|
|
-o $@ $(srcdir)/Modules/getbuildinfo.c
|
|
|
|
+# default sys.path calculations for posix platforms
|
|
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
|
$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
|
-DPREFIX='"$(prefix)"' \
|
|
@@ -755,6 +756,13 @@
|
|
-DVPATH='"$(VPATH)"' \
|
|
-o $@ $(srcdir)/Modules/getpath.c
|
|
|
|
+# default sys.path calculations for windows platforms
|
|
+PC/getpathp.o: $(srcdir)/PC/getpathp.c Makefile
|
|
+ $(CC) -c $(PY_CORE_CFLAGS) \
|
|
+ -DVERSION='"$(VERSION)"' \
|
|
+ -DSRCDIR='"$(srcdir)"' \
|
|
+ -o $@ $(srcdir)/PC/getpathp.c
|
|
+
|
|
Programs/python.o: $(srcdir)/Programs/python.c
|
|
$(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c
|
|
|
|
diff -Naur Python-3.5.2-orig/PC/getpathp.c Python-3.5.2/PC/getpathp.c
|
|
--- Python-3.5.2-orig/PC/getpathp.c 2016-06-26 00:38:38.000000000 +0300
|
|
+++ Python-3.5.2/PC/getpathp.c 2016-07-12 14:20:54.300800700 +0300
|
|
@@ -87,10 +87,26 @@
|
|
* with a semicolon separated path prior to calling Py_Initialize.
|
|
*/
|
|
|
|
+#ifndef PYTHONPATH
|
|
+# define PYTHONPATH L".\\DLLs;.\\lib"
|
|
+#endif
|
|
+
|
|
#ifndef LANDMARK
|
|
#define LANDMARK L"lib\\os.py"
|
|
#endif
|
|
|
|
+#ifdef __MINGW32__
|
|
+
|
|
+static wchar_t *lib_python = L"lib\\python" VERSION;
|
|
+
|
|
+# undef LANDMARK
|
|
+# define LANDMARK L"os.py"
|
|
+
|
|
+# define USE_POSIX_PREFIX
|
|
+
|
|
+#endif
|
|
+
|
|
+
|
|
static wchar_t prefix[MAXPATHLEN+1];
|
|
static wchar_t progpath[MAXPATHLEN+1];
|
|
static wchar_t dllpath[MAXPATHLEN+1];
|
|
@@ -183,6 +199,69 @@
|
|
Py_FatalError("buffer overflow in getpathp.c's join()");
|
|
}
|
|
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+
|
|
+/* based on getpath.c but with paths relative to executable */
|
|
+/* search_for_prefix requires that path be no more than MAXPATHLEN
|
|
+ bytes long.
|
|
+ return: 1 if found; -1 if found build directory
|
|
+*/
|
|
+static int
|
|
+search_for_posix_prefix(wchar_t *argv0_path, wchar_t *home, wchar_t *_prefix)
|
|
+{
|
|
+ size_t n;
|
|
+
|
|
+ /* If PYTHONHOME is set, we believe it unconditionally */
|
|
+ if (home) {
|
|
+ wchar_t *delim;
|
|
+ wcsncpy(prefix, home, MAXPATHLEN);
|
|
+ delim = wcschr(prefix, DELIM);
|
|
+ if (delim)
|
|
+ *delim = L'\0';
|
|
+ join(prefix, lib_python);
|
|
+ join(prefix, LANDMARK);
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
+ /* Check to see if argv[0] is in the build directory */
|
|
+ wcscpy(prefix, argv0_path);
|
|
+ join(prefix, L"Modules\\Setup");
|
|
+ if (exists(prefix)) {
|
|
+ wchar_t *vpath;
|
|
+ /* Check source directory if argv0_path is in the build directory. */
|
|
+ vpath = Py_DecodeLocale(SRCDIR, NULL);
|
|
+ if (vpath != NULL) {
|
|
+ wcscpy(prefix, argv0_path);
|
|
+ join(prefix, vpath);
|
|
+ PyMem_Free(vpath);
|
|
+ join(prefix, L"Lib");
|
|
+ join(prefix, LANDMARK);
|
|
+ if (ismodule(prefix))
|
|
+ return -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* Search from argv0_path, until root is found */
|
|
+ wcscpy(prefix, argv0_path);
|
|
+ do {
|
|
+ n = wcslen(prefix);
|
|
+ join(prefix, lib_python);
|
|
+ join(prefix, LANDMARK);
|
|
+ if (ismodule(prefix))
|
|
+ return 1;
|
|
+ prefix[n] = L'\0';
|
|
+ reduce(prefix);
|
|
+ } while (prefix[0]);
|
|
+
|
|
+ /* Configure prefix is unused */
|
|
+ (void)_prefix;
|
|
+
|
|
+ /* Fail */
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+#endif /*def USE_POSIX_PREFIX */
|
|
+
|
|
/* gotlandmark only called by search_for_prefix, which ensures
|
|
'prefix' is null terminated in bounds. join() ensures
|
|
'landmark' can not overflow prefix if too long.
|
|
@@ -491,6 +570,9 @@
|
|
size_t bufsz;
|
|
wchar_t *pythonhome = Py_GetPythonHome();
|
|
wchar_t *envpath = NULL;
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+ int pfound;
|
|
+#endif
|
|
|
|
#ifdef MS_WINDOWS
|
|
int skiphome, skipdefault;
|
|
@@ -563,6 +645,16 @@
|
|
}
|
|
}
|
|
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+ pfound = search_for_posix_prefix(argv0_path, pythonhome, NULL);
|
|
+ if (!pfound) {
|
|
+ wcsncpy(prefix, argv0_path, MAXPATHLEN);
|
|
+ reduce(prefix);
|
|
+ join(prefix, lib_python);
|
|
+ }
|
|
+ else
|
|
+ reduce(prefix);
|
|
+#else
|
|
if (pythonhome == NULL || *pythonhome == '\0') {
|
|
if (search_for_prefix(argv0_path, LANDMARK))
|
|
pythonhome = prefix;
|
|
@@ -571,11 +663,11 @@
|
|
}
|
|
else
|
|
wcscpy_s(prefix, MAXPATHLEN+1, pythonhome);
|
|
+#endif
|
|
|
|
if (envpath && *envpath == '\0')
|
|
envpath = NULL;
|
|
|
|
-
|
|
#ifdef MS_WINDOWS
|
|
/* Calculate zip archive path from DLL or exe path */
|
|
if (wcscpy_s(zip_path, MAXPATHLEN+1, dllpath[0] ? dllpath : progpath))
|
|
@@ -627,6 +719,9 @@
|
|
}
|
|
else
|
|
bufsz = 0;
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+ bufsz += wcslen(prefix) + 1;
|
|
+#endif
|
|
bufsz += wcslen(PYTHONPATH) + 1;
|
|
bufsz += wcslen(argv0_path) + 1;
|
|
#ifdef MS_WINDOWS
|
|
@@ -671,6 +766,11 @@
|
|
buf = wcschr(buf, L'\0');
|
|
*buf++ = DELIM;
|
|
}
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+ wcscpy(buf, prefix);
|
|
+ buf = wcschr(buf, L'\0');
|
|
+ *buf++ = DELIM;
|
|
+#endif
|
|
if (userpath) {
|
|
if (wcscpy_s(buf, bufsz - (buf - module_search_path), userpath))
|
|
Py_FatalError("buffer overflow in getpathp.c's calculate_path()");
|
|
@@ -739,6 +839,12 @@
|
|
on the path, and that our 'prefix' directory is
|
|
the parent of that.
|
|
*/
|
|
+#ifdef USE_POSIX_PREFIX
|
|
+ if (pfound > 0) {
|
|
+ reduce(prefix);
|
|
+ reduce(prefix);
|
|
+ }
|
|
+#endif
|
|
if (*prefix==L'\0') {
|
|
wchar_t lookBuf[MAXPATHLEN+1];
|
|
wchar_t *look = buf - 1; /* 'buf' is at the end of the buffer */
|