diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac
--- Python-3.8.0-orig/configure.ac	2019-10-22 10:00:52.028128100 +0300
+++ Python-3.8.0/configure.ac	2019-10-22 10:00:53.198130100 +0300
@@ -574,6 +574,14 @@
   AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc)
 fi
 
+AC_MSG_CHECKING([for init system calls])
+AC_SUBST(INITSYS)
+case $host in
+  *-*-mingw*)	INITSYS=nt;;
+  *)		INITSYS=posix;;
+esac
+AC_MSG_RESULT([$INITSYS])
+
 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
 # it may influence the way we can build extensions, so distutils
 # needs to check it
--- Python-3.8.1/Modules/posixmodule.c.orig	2019-12-18 18:21:23.000000000 +0100
+++ Python-3.8.1/Modules/posixmodule.c	2019-12-23 10:35:51.095967700 +0100
@@ -193,6 +193,27 @@
 #define HAVE_CWAIT      1
 #define HAVE_FSYNC      1
 #define fsync _commit
+#elif defined(__MINGW32__)	/* GCC for windows hosts */
+/* getlogin is detected by configure on mingw-w64 */
+#undef HAVE_GETLOGIN
+/*#define HAVE_GETCWD	1 - detected by configure*/
+#define HAVE_GETPPID    1
+#define HAVE_GETLOGIN   1
+#define HAVE_SPAWNV	1
+#define HAVE_WSPAWNV    1
+#define HAVE_WEXECV    1
+/*#define HAVE_EXECV	1 - detected by configure*/
+#define HAVE_PIPE	1
+#define HAVE_POPEN	1
+#define HAVE_SYSTEM	1
+#define HAVE_CWAIT	1
+#define HAVE_FSYNC	1
+#define fsync _commit
+#include <windows.h>
+#include <winioctl.h>
+#ifndef _MAX_ENV
+#define _MAX_ENV	32767
+#endif
 #else
 /* Unix functions that the configure script doesn't check for */
 #ifndef __VXWORKS__
@@ -292,7 +313,7 @@
 #endif
 #endif
 
-#ifdef _MSC_VER
+#ifdef MS_WINDOWS
 #ifdef HAVE_DIRECT_H
 #include <direct.h>
 #endif
@@ -314,7 +335,7 @@
 #include <shellapi.h>   /* for ShellExecute() */
 #include <lmcons.h>     /* for UNLEN */
 #define HAVE_SYMLINK
-#endif /* _MSC_VER */
+#endif /* MS_WINDOWS */
 
 #ifndef MAXPATHLEN
 #if defined(PATH_MAX) && PATH_MAX > 1024
@@ -1372,9 +1393,9 @@
 ** man environ(7).
 */
 #include <crt_externs.h>
-#elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
+#elif !defined(MS_WINDOWS) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
 extern char **environ;
-#endif /* !_MSC_VER */
+#endif /* !MS_WINDOWS */
 
 static PyObject *
 convertenviron(void)
diff -Naur Python-3.8.0-orig/Modules/Setup Python-3.8.0/Modules/Setup
--- Python-3.8.0-orig/Modules/Setup	2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0/Modules/Setup	2019-10-22 10:00:54.430532300 +0300
@@ -101,7 +101,6 @@
 # This only contains the minimal set of modules required to run the
 # setup.py script in the root of the Python source tree.
 
-posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c # posix (UNIX) system calls
 errno errnomodule.c			# posix (UNIX) errno values
 pwd pwdmodule.c				# this is needed to find out the user's home dir
 					# if $HOME is not set
diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in
--- Python-3.8.0-orig/Modules/Setup.config.in	2019-10-22 10:00:30.171489600 +0300
+++ Python-3.8.0/Modules/Setup.config.in	2019-10-22 10:00:54.009331600 +0300
@@ -3,3 +3,6 @@
 # The purpose of this file is to conditionally enable certain modules
 # based on configure-time options.
 
+# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
+@INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
+
