Blob Blame History Raw
diff -rupN Python-2.7.13/configure.ac Python-2.7.13-new/configure.ac
--- Python-2.7.13/configure.ac	2017-01-21 01:46:10.748562266 +0100
+++ Python-2.7.13-new/configure.ac	2017-01-21 01:46:11.036559191 +0100
@@ -568,6 +568,65 @@ fi
 AC_MSG_RESULT([$DELIM])
 AC_SUBST(DELIM)
 
+# On 'semi-native' build systems (MSYS*/Cygwin targeting MinGW-w64)
+# _sysconfigdata.py will contain paths that are correct only in the
+# build environment. This means external modules will fail to build
+# without setting up the same env and also that the build of Python
+# itself will fail as the paths are not correct for the host tools.
+#
+# Also, getpath.c uses GetModuleFileNameW (replacing \ with /) and
+# compares that with the define VPATH (passed in via command-line)
+# to determine whether it's the build- or the installed-Python.
+#
+# To work around these issues a set of _b2h variables are created:
+# VPATH_b2h, prefix_b2h, srcdir_b2h, abs_srcdir_b2h
+# and abs_builddir_b2h
+# .. where b2h stands for build to host. sysconfig.py replaces path
+# prefixes matching the non-b2h versions with the b2h equivalents.
+#
+# (note this assumes the host compilers are native and *not* cross
+#  - in the 'semi-native' scenario only that is.)
+
+AC_DEFUN([ABS_PATH_HOST],
+[$1=$(cd $$2 && pwd)
+  case $build_os in
+    mingw*)
+      case $host_os in
+        mingw*) $1=$(cd $$2 && pwd -W) ;;
+        *) ;;
+      esac
+      ;;
+    cygwin*)
+      case $host_os in
+        mingw*) $1=$(cygpath -w -m $$2) ;;
+        *) ;;
+      esac
+      ;;
+  esac
+AC_SUBST([$1])
+])
+
+AC_MSG_CHECKING(absolute host location of VPATH)
+ABS_PATH_HOST([VPATH_b2h],[srcdir])
+AC_MSG_RESULT([$VPATH_b2h])
+
+AC_MSG_CHECKING(absolute host location of prefix)
+ABS_PATH_HOST([prefix_b2h],[prefix])
+AC_MSG_RESULT([$prefix_b2h])
+
+AC_MSG_CHECKING(absolute host location of srcdir)
+ABS_PATH_HOST([srcdir_b2h],[srcdir])
+AC_MSG_RESULT([$srcdir_b2h])
+
+AC_MSG_CHECKING(absolute host location of abs_srcdir)
+ABS_PATH_HOST([abs_srcdir_b2h],[srcdir])
+AC_MSG_RESULT([$abs_srcdir_b2h])
+
+my_builddir=.
+AC_MSG_CHECKING(Absolute host location of abs_builddir)
+ABS_PATH_HOST([abs_builddir_b2h],[my_builddir])
+AC_MSG_RESULT([$abs_builddir_b2h])
+
 AC_MSG_CHECKING([for init system calls])
 AC_SUBST(INITSYS)
 case $host in
diff -rupN Python-2.7.13/Lib/sysconfig.py Python-2.7.13-new/Lib/sysconfig.py
--- Python-2.7.13/Lib/sysconfig.py	2017-01-21 01:46:08.852582508 +0100
+++ Python-2.7.13-new/Lib/sysconfig.py	2017-01-21 01:46:11.037559180 +0100
@@ -273,6 +273,14 @@ def _parse_makefile(filename, vars=None)
         if isinstance(v, str):
             done[k] = v.strip()
 
+    # any keys that have one with the same name suffixed with _b2h
+    # need to be replaced with the value of the _b2h key.
+    # This converts from MSYS*/Cygwin paths to Windows paths.
+    for k, v in done.items():
+        if isinstance(k, str):
+            if k.endswith("_b2h"):
+                done[k[:-4]]=v
+ 
     # save the results in the global dictionary
     vars.update(done)
     return vars
diff -rupN Python-2.7.13/Makefile.pre.in Python-2.7.13-new/Makefile.pre.in
--- Python-2.7.13/Makefile.pre.in	2017-01-21 01:46:10.889560760 +0100
+++ Python-2.7.13-new/Makefile.pre.in	2017-01-21 01:46:11.037559180 +0100
@@ -106,6 +106,13 @@ exec_prefix=	@exec_prefix@
 # Install prefix for data files
 datarootdir=    @datarootdir@
 
+# Locations needed for semi-native fixup of sysconfig.
+srcdir_b2h=		@srcdir_b2h@
+VPATH_b2h=		@VPATH_b2h@
+abs_srcdir_b2h=		@abs_srcdir_b2h@
+abs_builddir_b2h=	@abs_builddir_b2h@
+prefix_b2h=		@prefix_b2h@
+
 # Expanded directories
 BINDIR=		@bindir@
 LIBDIR=		@libdir@
@@ -669,7 +676,7 @@ Modules/getpath.o: $(srcdir)/Modules/get
 		-DPREFIX='"$(prefix)"' \
 		-DEXEC_PREFIX='"$(exec_prefix)"' \
 		-DVERSION='"$(VERSION)"' \
-		-DVPATH='"$(VPATH)"' \
+		-DVPATH='"$(VPATH_b2h)"' \
 		-o $@ $(srcdir)/Modules/getpath.c
 
 # default sys.path calculations for windows platforms