Blame 0610-msys-cygwin-semi-native-build-sysconfig.patch

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