]> granicus.if.org Git - postgresql/commitdiff
Try to fix python shlib probe for MinGW.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Oct 2016 02:47:23 +0000 (22:47 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Oct 2016 02:47:23 +0000 (22:47 -0400)
Per discussion with Andrew Dunstan, it seems there are three peculiarities
of the Python installation on MinGW (or at least, of the instance on
buildfarm member frogmouth).  First, the library name doesn't contain
"2.7" but just "27".  It looks like we can deal with that by consulting
get_config_vars('VERSION') to see whether a dot should be used or not.
Second, the library might be in c:/Windows/System32, analogously to it
possibly being in /usr/lib on Unix-oid platforms.  Third, it's apparently
not standard to use the prefix "lib" on the file name.  This patch will
accept files with or without "lib", but the first part of that may well
be dead code.

config/python.m4
configure

index e29f05987b5561c95eb301f70d9adece12be97d6..babf5ab1dbe898fab3a9f3698c72f24982659c34 100644 (file)
@@ -88,12 +88,18 @@ then
        found_shlib=1
 else
        # Otherwise, guess the base name of the shlib.
-       # LDVERSION was added in Python 3.2, before that use $python_version.
+       # LDVERSION was added in Python 3.2, before that use VERSION,
+       # or failing that, $python_version from _PGAC_CHECK_PYTHON_DIRS.
        python_ldversion=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDVERSION'))))"`
        if test x"${python_ldversion}" != x""; then
                ldlibrary="python${python_ldversion}"
        else
-               ldlibrary="python${python_version}"
+               python_version_var=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('VERSION'))))"`
+               if test x"${python_version_var}" != x""; then
+                       ldlibrary="python${python_version_var}"
+               else
+                       ldlibrary="python${python_version}"
+               fi
        fi
        # Search for a likely-looking file.
        found_shlib=0
@@ -124,6 +130,21 @@ else
                        done
                done
        fi
+       # As usual, Windows has its own ideas.  c:/Windows/System32 takes the
+       # place of /usr/lib as a possible default library location, and the
+       # "lib" prefix might not be there.
+       if test "$found_shlib" != 1 -a "$PORTNAME" = win32 ; then
+               for d in "${python_libdir}" "${python_configdir}" c:/Windows/System32
+               do
+                       for f in "$d/lib${ldlibrary}.dll" "$d/${ldlibrary}.dll" ; do
+                               if test -e "$f"; then
+                                       python_libdir="$d"
+                                       found_shlib=1
+                                       break 2
+                               fi
+                       done
+               done
+       fi
 fi
 if test "$found_shlib" != 1; then
        AC_MSG_ERROR([could not find shared library for Python
index 3d08f5a5e9514839886a23d98c9e158e951f0652..204daa056d5bceaadb8a90d5d872766453a110a0 100755 (executable)
--- a/configure
+++ b/configure
@@ -7631,12 +7631,18 @@ then
        found_shlib=1
 else
        # Otherwise, guess the base name of the shlib.
-       # LDVERSION was added in Python 3.2, before that use $python_version.
+       # LDVERSION was added in Python 3.2, before that use VERSION,
+       # or failing that, $python_version from _PGAC_CHECK_PYTHON_DIRS.
        python_ldversion=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDVERSION'))))"`
        if test x"${python_ldversion}" != x""; then
                ldlibrary="python${python_ldversion}"
        else
-               ldlibrary="python${python_version}"
+               python_version_var=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('VERSION'))))"`
+               if test x"${python_version_var}" != x""; then
+                       ldlibrary="python${python_version_var}"
+               else
+                       ldlibrary="python${python_version}"
+               fi
        fi
        # Search for a likely-looking file.
        found_shlib=0
@@ -7667,6 +7673,21 @@ else
                        done
                done
        fi
+       # As usual, Windows has its own ideas.  c:/Windows/System32 takes the
+       # place of /usr/lib as a possible default library location, and the
+       # "lib" prefix might not be there.
+       if test "$found_shlib" != 1 -a "$PORTNAME" = win32 ; then
+               for d in "${python_libdir}" "${python_configdir}" c:/Windows/System32
+               do
+                       for f in "$d/lib${ldlibrary}.dll" "$d/${ldlibrary}.dll" ; do
+                               if test -e "$f"; then
+                                       python_libdir="$d"
+                                       found_shlib=1
+                                       break 2
+                               fi
+                       done
+               done
+       fi
 fi
 if test "$found_shlib" != 1; then
        as_fn_error $? "could not find shared library for Python