--- postgresql-9.5.1/src/pl/plpython/Makefile.orig	2015-02-02 23:42:55.000000000 +0300
+++ postgresql-9.5.1/src/pl/plpython/Makefile	2015-02-10 21:33:26.353400000 +0300
@@ -5,11 +5,6 @@
 include $(top_builddir)/src/Makefile.global
 
 
-# On Windows we have to remove -lpython from the link since we are
-# building our own
-ifeq ($(PORTNAME), win32)
-override python_libspec =
-endif
 
 override CPPFLAGS := -I. -I$(srcdir) $(python_includespec) $(CPPFLAGS)
 
@@ -59,25 +57,6 @@
 	plpy_typeio.h \
 	plpy_util.h
 
-# Python on win32 ships with import libraries only for Microsoft Visual C++,
-# which are not compatible with mingw gcc. Therefore we need to build a
-# new import library to link with.
-ifeq ($(PORTNAME), win32)
-
-pytverstr=$(subst .,,${python_version})
-PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
-
-OBJS += libpython${pytverstr}.a
-
-libpython${pytverstr}.a: python${pytverstr}.def
-	dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib libpython${pytverstr}.a
-
-python${pytverstr}.def:
-	pexports $(PYTHONDLL) > $@
-
-endif # win32
-
-
 SHLIB_LINK = $(python_libspec) $(python_additional_libs) $(filter -lintl,$(LIBS))
 
 REGRESS_OPTS = --dbname=$(PL_TESTDB)
@@ -187,9 +165,6 @@
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-ifeq ($(PORTNAME), win32)
-	rm -f python${pytverstr}.def
-endif
 
 else # can't build
 
--- postgresql-10.1/config/python.m4.orig	2017-12-01 08:18:11.189297000 +0300
+++ postgresql-10.1/config/python.m4	2017-12-01 08:18:22.161116600 +0300
@@ -88,7 +88,7 @@
 python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
 
 # If LDLIBRARY exists and has a shlib extension, use it verbatim.
-ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
+ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dll.a$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
 if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}"
 then
 	ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
