Index: Python/import.c =================================================================== --- Python/import.c (revision 83626) +++ Python/import.c (working copy) @@ -1132,7 +1132,7 @@ time_t mtime = srcstat->st_mtime; #ifdef MS_WINDOWS /* since Windows uses different permissions */ mode_t mode = srcstat->st_mode & ~S_IEXEC; - mode_t dirmode = srcstat->st_mode | S_IEXEC; /* XXX Is this correct + /*mode_t dirmode = srcstat->st_mode | S_IEXEC; *//* XXX Is this correct for Windows? 2010-04-07 BAW */ #else @@ -1155,7 +1155,13 @@ saved = *dirpath; *dirpath = '\0'; /* XXX call os.mkdir() or maybe CreateDirectoryA() on Windows? */ +#ifndef MS_WINDOWS if (mkdir(cpathname, dirmode) < 0 && errno != EEXIST) { +#else + /* Assigning proper permissions requires somewhat more sophisticated + mkdir() implementation; ignore it for now */ + if (mkdir(cpathname) < 0 && errno != EEXIST) { +#endif *dirpath = saved; if (Py_VerboseFlag) PySys_WriteStderr( Index: Python/dynload_win.c =================================================================== --- Python/dynload_win.c (revision 83626) +++ Python/dynload_win.c (working copy) @@ -26,9 +26,9 @@ /* Case insensitive string compare, to avoid any dependencies on particular - C RTL implementations */ - -static int strcasecmp (char *string1, char *string2) + C RTL implementations. Name it differently to avoid conflicts with + existing function. */ +static int pystrcasecmp (char *string1,char *string2) { int first, second; @@ -261,7 +261,7 @@ import_python = GetPythonImport(hDLL); if (import_python && - strcasecmp(buffer,import_python)) { + pystrcasecmp(buffer,import_python)) { PyOS_snprintf(buffer, sizeof(buffer), "Module use of %.150s conflicts " "with this version of Python.", Index: Python/thread.c =================================================================== --- Python/thread.c (revision 83626) +++ Python/thread.c (working copy) @@ -12,7 +12,7 @@ /* This means pthreads are not implemented in libc headers, hence the macro not present in unistd.h. But they still can be implemented as an external library (e.g. gnu pth in pthread emulation) */ -# ifdef HAVE_PTHREAD_H +# if defined(HAVE_PTHREAD_H) && !defined(NT_THREADS) # include /* _POSIX_THREADS */ # endif #endif Index: Python/ceval_gil.h =================================================================== --- Python/ceval_gil.h (revision 83626) +++ Python/ceval_gil.h (working copy) @@ -63,7 +63,7 @@ /* This means pthreads are not implemented in libc headers, hence the macro not present in unistd.h. But they still can be implemented as an external library (e.g. gnu pth in pthread emulation) */ -# ifdef HAVE_PTHREAD_H +# if defined(HAVE_PTHREAD_H) && !defined(NT_THREADS) # include /* _POSIX_THREADS */ # endif #endif Index: Include/osdefs.h =================================================================== --- Include/osdefs.h (revision 83626) +++ Include/osdefs.h (working copy) @@ -10,15 +10,17 @@ /* Mod by chrish: QNX has WATCOM, but isn't DOS */ #if !defined(__QNX__) #if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) -#if defined(PYOS_OS2) && defined(PYCC_GCC) +#if defined(PYOS_OS2) && defined(PYCC_GCC) && !defined(__MINGW32__) #define MAXPATHLEN 260 #define SEP L'/' #define ALTSEP L'\\' #else #define SEP L'\\' #define ALTSEP L'/' +#ifndef MAXPATHLEN /* MinGW defines MAXPATHLEN in sys/param.h */ #define MAXPATHLEN 256 #endif +#endif #define DELIM L';' #endif #endif Index: configure.in =================================================================== --- configure.in (revision 83626) +++ configure.in (working copy) @@ -290,12 +290,35 @@ case $MACHDEP in cygwin*) MACHDEP="cygwin";; + mingw32_nt*) MACHDEP="win32";; darwin*) MACHDEP="darwin";; irix646) MACHDEP="irix6";; '') MACHDEP="unknown";; esac fi - + +AC_SUBST(MACHDEP_PATH_SEPARATOR) +MACHDEP_PATH_SEPARATOR=":" +AC_SUBST(NTOBJS) +NTOBJS="" +AC_SUBST(FROZEN_MAIN) +FROZEN_MAIN="Python/frozenmain.o" +AC_SUBST(NT_LDFLAGS) +NT_LDFLAGS="" +AC_SUBST(SHAREDINSTALL) +SHAREDINSTALL=sharedinstall +AC_SUBST(USE_PWD_MODULE) +AC_SUBST(USE_POSIX_MODULE) +AC_SUBST(USE_NT_MODULE) +AC_SUBST(USE_MSYS_MODULE) +AC_SUBST(USE__COLLECTIONS_MODULE) +USE_PWD_MODULE="" +USE_POSIX_MODULE="" +USE_NT_MODULE="#" +USE_MSYS_MODULE="#" +USE__COLLECTIONS_MODULE="#" +ms_windows=no + # Some systems cannot stand _XOPEN_SOURCE being defined at all; they # disable features if it is defined, without any means to access these # features as extensions. For these systems, we skip the definition of @@ -376,7 +399,27 @@ QNX/6.3.2) define_xopen_source=no ;; - + # Enables compilation of Windows-specific code instead of *nix-specific + # one (which is by default). This case will likely be triggered by any + # Windows (x64 and CE too), so patches are welcome. + MINGW32_NT*/1.*) + AC_DEFINE(MS_WIN32, 1, [Define on Windows (32- or 64-bit)]) + AC_DEFINE(MS_WINDOWS, 1, [Define on Windows (any version)]) + AC_DEFINE(WINVER, 0x0600, [Minimal version of Windows supported]) + # This is used to allow extensions to find -lpythonx.x + NT_LDFLAGS="-L\$(srcdir)/" + USE_PWD_MODULE="#" + USE_POSIX_MODULE="#" + USE_NT_MODULE="" + USE_MSYS_MODULE="" + USE__COLLECTIONS_MODULE="" + ms_windows=yes + FROZEN_MAIN="" + NTOBJS="PC/import_nt.o PC/dl_nt.o" + MACHDEP_PATH_SEPARATOR=";" + SHAREDINSTALL=msyssharedinstall + # This small hack is supposed to prevent MSys from mangling this path + ;; esac if test $define_xopen_source = yes @@ -667,7 +710,7 @@ if test -z "$enable_shared" then case $ac_sys_system in - CYGWIN*) + CYGWIN*|MINGW32*) enable_shared="yes";; *) enable_shared="no";; @@ -715,9 +758,10 @@ if test $enable_shared = "yes"; then AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) case $ac_sys_system in - CYGWIN*) + CYGWIN*|MINGW32*) LDLIBRARY='libpython$(VERSION).dll.a' DLLLIBRARY='libpython$(VERSION).dll' + AC_DEFINE(MS_COREDLL, 1, [Deprecated symbol for b/w compatibility.]) ;; SunOS*) LDLIBRARY='libpython$(VERSION).so' @@ -762,7 +806,7 @@ esac else # shared is disabled case $ac_sys_system in - CYGWIN*) + CYGWIN*|MINGW32*) BLDLIBRARY='$(LIBRARY)' LDLIBRARY='libpython$(VERSION).dll.a' ;; @@ -1247,6 +1291,32 @@ AC_MSG_RESULT($ac_cv_pthread) fi +# Check for NT threads, and use them instead of anything else if possible. +# No sense in relying on w32-pthreads when Python can use the underlying API +# already. +AC_MSG_CHECKING(for NT threads) +AC_CACHE_VAL(ac_cv_nt_threads, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +DWORD WINAPI routine(LPVOID lpParameter){return NULL;} + +int main(){ + HANDLE p; + p = CreateThread (NULL, 0, &routine, NULL, 0, NULL); + if (p == NULL) + return 1; + return 0; +} +]])],[ + ac_cv_nt_threads=yes + ac_cv_kthread=no + ac_cv_pthread=no + ac_cv_pthread_is_default=no +],[ac_cv_nt_threads=no],[ac_cv_nt_threads=no]) +]) +AC_MSG_RESULT($ac_cv_nt_threads) + # If we have set a CC compiler flag for thread support then # check if it works for CXX, too. ac_cv_cxx_thread=no @@ -1300,15 +1370,15 @@ AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ -shadow.h signal.h stdint.h stropts.h termios.h thread.h \ +pwd.h shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ -sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ -sys/lock.h sys/mkdev.h sys/modem.h \ +sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/ioctl.h \ +sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ sys/termio.h sys/time.h \ -sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ -sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) +sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h syslog.h termios.h \ +pty.h libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ +bluetooth/bluetooth.h linux/tipc.h spawn.h util.h ws2tcpip.h) AC_HEADER_DIRENT AC_HEADER_MAJOR @@ -1654,7 +1724,7 @@ *) SO=.sl;; esac ;; - CYGWIN*) SO=.dll;; + CYGWIN*|MINGW32*) SO=.dll;; *) SO=.so;; esac else @@ -1804,6 +1874,9 @@ CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base" LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; + MINGW32*) + LDSHARED="gcc -shared -Wl,--enable-auto-image-base" + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; *) LDSHARED="ld";; esac fi @@ -1886,6 +1959,11 @@ then LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' fi;; + MINGW32*) + if test $enable_shared = "no" + then + LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' + fi;; QNX*) # -Wl,-E causes the symbols to be added to the dynamic # symbol table so that they can be found when a module @@ -1903,7 +1981,7 @@ if test ! "$LIBRARY" = "$LDLIBRARY" then case $ac_sys_system in - CYGWIN*) + CYGWIN*|MINGW32*) # Cygwin needs CCSHARED when building extension DLLs # but not when building the interpreter DLL. CFLAGSFORSHARED='';; @@ -2088,6 +2166,7 @@ # Defining _REENTRANT on system with POSIX threads should not hurt. AC_DEFINE(_REENTRANT) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o" elif test "$ac_cv_kpthread" = "yes" then @@ -2097,6 +2176,7 @@ fi AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o" elif test "$ac_cv_kthread" = "yes" then @@ -2106,6 +2186,7 @@ fi AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o" elif test "$ac_cv_pthread" = "yes" then @@ -2115,7 +2196,14 @@ fi AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o" +elif test "$ac_cv_nt_threads" = "yes" +then + AC_DEFINE(WITH_THREAD) + posix_threads=no + nt_threads=yes + THREADOBJ="Python/thread.o" else if test ! -z "$with_threads" -a -d "$with_threads" then LDFLAGS="$LDFLAGS -L$with_threads" @@ -2162,25 +2250,31 @@ AC_MSG_RESULT(yes) AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o"],[ LIBS=$_libs AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no THREADOBJ="Python/thread.o"],[ AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no LIBS="$LIBS -lpthreads" THREADOBJ="Python/thread.o"], [ AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no LIBS="$LIBS -lc_r" THREADOBJ="Python/thread.o"], [ AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no LIBS="$LIBS -lpthread" THREADOBJ="Python/thread.o"], [ AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) posix_threads=yes + nt_threads=no LIBS="$LIBS -lcma" THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) @@ -2257,6 +2351,10 @@ [Define if pthread_sigmask() does not work on your system.]) ;; esac]) +elif test "$nt_threads" = "yes"; then + AC_DEFINE(NT_THREADS, 1, + [Define if you have NT threads, + and your system does not define that.]) fi @@ -2539,6 +2637,7 @@ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; + MINGW32*) DYNLOADFILE="dynload_win.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub # out any dynamic loading @@ -2579,8 +2678,8 @@ select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ setgid \ setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \ - sigaction siginterrupt sigrelse snprintf strftime strlcpy \ - sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ + sigaction siginterrupt sigrelse snprintf spawn spawnv strftime strlcpy \ + sysconf system tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv utimes waitpid wait3 wait4 \ wcscoll wcsftime wcsxfrm _getpty) @@ -2990,6 +3089,12 @@ AC_CHECK_MEMBERS([struct stat.st_birthtime]) AC_STRUCT_ST_BLOCKS +dnl +dnl Remove fileblocks.o from the object list. This file gets added by +dnl the Autoconf macro AC_STRUCT_ST_BLOCKS. But there is no need. +LIBOBJS="`echo ${LIBOBJS} | sed 's/fileblocks\.o//g'`" + + AC_MSG_CHECKING(for time.h that defines altzone) AC_CACHE_VAL(ac_cv_header_time_altzone,[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return altzone;]])], @@ -3063,8 +3168,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], [AC_DEFINE(HAVE_PROTOTYPES, 1, [Define if your compiler supports function prototype]) - have_prototypes=yes], - [] + have_prototypes=yes] ) AC_MSG_RESULT($have_prototypes) @@ -3972,7 +4076,7 @@ AC_MSG_CHECKING(for /dev/ptmx) -if test -r /dev/ptmx +if test -r /dev/ptmx -a "$ms_windows" = no then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_DEV_PTMX, 1, @@ -4087,8 +4191,13 @@ [ac_cv_have_size_t_format="cross -- assuming yes" ])]) if test "$ac_cv_have_size_t_format" != no ; then - AC_DEFINE(PY_FORMAT_SIZE_T, "z", - [Define to printf format modifier for Py_ssize_t]) + if test "$ms_windows" != yes ; then + AC_DEFINE(PY_FORMAT_SIZE_T, "z", + [Define to printf format modifier for Py_ssize_t]) + else + AC_DEFINE(PY_FORMAT_SIZE_T, "lu", + [Define to printf format modifier for Py_ssize_t]) + fi fi AC_CHECK_TYPE(socklen_t,, @@ -4100,6 +4209,9 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif ]) AC_MSG_CHECKING(for broken mbstowcs) @@ -4155,7 +4267,7 @@ done AC_SUBST(SRCDIRS) -SRCDIRS="Parser Grammar Objects Python Modules Mac" +SRCDIRS="Parser Grammar Objects Python Modules Mac PC" AC_MSG_CHECKING(for build directories) for dir in $SRCDIRS; do if test ! -d $dir; then Index: setup.py =================================================================== --- setup.py (revision 83626) +++ setup.py (working copy) @@ -15,6 +15,7 @@ from distutils.command.install import install from distutils.command.install_lib import install_lib from distutils.spawn import find_executable +from distutils.util import msysize # Were we compiled --with-pydebug or with #define Py_DEBUG? COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') @@ -256,7 +257,6 @@ print() def build_extension(self, ext): - if ext.name == '_ctypes': if not self.configure_ctypes(ext): return @@ -303,6 +303,10 @@ # cached. Clear that cache before trying to import. sys.path_importer_cache.clear() + # Add the module's location to sys.path in case it tries to + # import itself recursively (multiprocessing does that) + sys.path.append (os.path.dirname (ext_filename)) + try: imp.load_dynamic(ext.name, ext_filename) except ImportError as why: @@ -485,11 +489,20 @@ # supported...) # fcntl(2) and ioctl(2) - exts.append( Extension('fcntl', ['fcntlmodule.c']) ) + if config_h_vars.get('HAVE_SYS_FCNTL_H', False): + exts.append( Extension('fcntl', ['fcntlmodule.c']) ) + else: + missing.append('fcntl') # pwd(3) - exts.append( Extension('pwd', ['pwdmodule.c']) ) + if config_h_vars.get('HAVE_PWD_H', False): + exts.append( Extension('pwd', ['pwdmodule.c']) ) + else: + missing.append('pwd') # grp(3) - exts.append( Extension('grp', ['grpmodule.c']) ) + if config_h_vars.get('HAVE_GRP_H', False): + exts.append( Extension('grp', ['grpmodule.c']) ) + else: + missing.append('grp') # spwd, shadow passwords if (config_h_vars.get('HAVE_GETSPNAM', False) or config_h_vars.get('HAVE_GETSPENT', False)): @@ -498,7 +511,9 @@ missing.append('spwd') # select(2); not on ancient System V - exts.append( Extension('select', ['selectmodule.c']) ) + exts.append( Extension('select', ['selectmodule.c'], + libraries=[] if 'msys' not in sys.builtin_module_names else ['ws2_32'] + ) ) # Fred Drake's interface to the Python parser exts.append( Extension('parser', ['parsermodule.c']) ) @@ -508,7 +523,10 @@ # Lance Ellinghaus's syslog module # syslog daemon interface - exts.append( Extension('syslog', ['syslogmodule.c']) ) + if config_h_vars.get('HAVE_SYSLOG_H', False): + exts.append( Extension('syslog', ['syslogmodule.c']) ) + else: + missing.append('syslog') # # Here ends the simple stuff. From here on, modules need certain @@ -603,17 +621,24 @@ libs = ['crypt'] else: libs = [] - exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) + if 'msys' not in sys.builtin_module_names: + exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) + else: + missing.append('crypt') # CSV files exts.append( Extension('_csv', ['_csv.c']) ) # POSIX subprocess module helper. - exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) ) + if config_h_vars.get('HAVE_FORK', False): + exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) ) + else: + missing.append('_posixsubprocess') # socket(2) exts.append( Extension('_socket', ['socketmodule.c'], - depends = ['socketmodule.h']) ) + depends = ['socketmodule.h'], + libraries=[] if 'msys' not in sys.builtin_module_names else ['ws2_32']) ) # Detect SSL support for the socket module (via _ssl) search_for_ssl_incs_in = [ '/usr/local/ssl/include', @@ -969,10 +994,7 @@ '_sqlite/util.c', ] sqlite_defines = [] - if sys.platform != "win32": - sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) - else: - sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) + sqlite_defines.append(('MODULE_NAME', 'sqlite3')) # Comment this out if you want the sqlite3 module to be able to load extensions. sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) @@ -1297,11 +1319,13 @@ '_multiprocessing/socket_connection.c', '_multiprocessing/win32_functions.c' ] + multiprocessing_libs = ['ws2_32'] else: multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', '_multiprocessing/socket_connection.c' ] + multiprocessing_libs = [] if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): multiprocessing_srcs.append('_multiprocessing/semaphore.c') @@ -1309,7 +1333,9 @@ if sysconfig.get_config_var('WITH_THREAD'): exts.append ( Extension('_multiprocessing', multiprocessing_srcs, define_macros=list(macros.items()), - include_dirs=["Modules/_multiprocessing"])) + include_dirs=["Modules/_multiprocessing"], + libraries=multiprocessing_libs) + ) else: missing.append('_multiprocessing') # End multiprocessing @@ -1530,7 +1556,7 @@ libs.append('ld') # Finally, link with the X11 libraries (not appropriate on cygwin) - if platform != "cygwin": + if platform != "cygwin" and platform != "win32": libs.append('X11') ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], @@ -1602,11 +1628,17 @@ mkpath(ffi_builddir) config_args = [] + if 'msys' in sys.builtin_module_names: + w32_ffi_srcdir = ffi_srcdir + ffi_srcdir = msysize(ffi_srcdir) # Pass empty CFLAGS because we'll just append the resulting # CFLAGS to Python's; -g or -O2 is to be avoided. cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) + if 'msys' in sys.builtin_module_names: + ffi_srcdir = w32_ffi_srcdir + res = os.system(cmd) if res or not os.path.exists(ffi_configfile): print("Failed to configure _ctypes module") @@ -1668,10 +1700,11 @@ include_dirs=include_dirs, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, - libraries=[], + libraries=[] if 'msys' not in sys.builtin_module_names else ['uuid', 'ole32', 'oleaut32'], sources=sources, depends=depends) ext_test = Extension('_ctypes_test', + libraries=[] if 'msys' not in sys.builtin_module_names else ['oleaut32'], sources=['_ctypes/_ctypes_test.c']) self.extensions.extend([ext, ext_test]) Index: PC/errmap.h =================================================================== --- PC/errmap.h (revision 83626) +++ PC/errmap.h (working copy) @@ -1,78 +1,78 @@ /* Generated file. Do not edit. */ int winerror_to_errno(int winerror) { - switch(winerror) { - case 2: return 2; - case 3: return 2; - case 4: return 24; - case 5: return 13; - case 6: return 9; - case 7: return 12; - case 8: return 12; - case 9: return 12; - case 10: return 7; - case 11: return 8; - case 15: return 2; - case 16: return 13; - case 17: return 18; - case 18: return 2; - case 19: return 13; - case 20: return 13; - case 21: return 13; - case 22: return 13; - case 23: return 13; - case 24: return 13; - case 25: return 13; - case 26: return 13; - case 27: return 13; - case 28: return 13; - case 29: return 13; - case 30: return 13; - case 31: return 13; - case 32: return 13; - case 33: return 13; - case 34: return 13; - case 35: return 13; - case 36: return 13; - case 53: return 2; - case 65: return 13; - case 67: return 2; - case 80: return 17; - case 82: return 13; - case 83: return 13; - case 89: return 11; - case 108: return 13; - case 109: return 32; - case 112: return 28; - case 114: return 9; - case 128: return 10; - case 129: return 10; - case 130: return 9; - case 132: return 13; - case 145: return 41; - case 158: return 13; - case 161: return 2; - case 164: return 11; - case 167: return 13; - case 183: return 17; - case 188: return 8; - case 189: return 8; - case 190: return 8; - case 191: return 8; - case 192: return 8; - case 193: return 8; - case 194: return 8; - case 195: return 8; - case 196: return 8; - case 197: return 8; - case 198: return 8; - case 199: return 8; - case 200: return 8; - case 201: return 8; - case 202: return 8; - case 206: return 2; - case 215: return 11; - case 1816: return 12; - default: return EINVAL; - } + switch(winerror) { + case 2: return 2; + case 3: return 2; + case 4: return 24; + case 5: return 13; + case 6: return 9; + case 7: return 12; + case 8: return 12; + case 9: return 12; + case 10: return 7; + case 11: return 8; + case 15: return 2; + case 16: return 13; + case 17: return 18; + case 18: return 2; + case 19: return 13; + case 20: return 13; + case 21: return 13; + case 22: return 13; + case 23: return 13; + case 24: return 13; + case 25: return 13; + case 26: return 13; + case 27: return 13; + case 28: return 13; + case 29: return 13; + case 30: return 13; + case 31: return 13; + case 32: return 13; + case 33: return 13; + case 34: return 13; + case 35: return 13; + case 36: return 13; + case 53: return 2; + case 65: return 13; + case 67: return 2; + case 80: return 17; + case 82: return 13; + case 83: return 13; + case 89: return 11; + case 108: return 13; + case 109: return 32; + case 112: return 28; + case 114: return 9; + case 128: return 10; + case 129: return 10; + case 130: return 9; + case 132: return 13; + case 145: return 41; + case 158: return 13; + case 161: return 2; + case 164: return 11; + case 167: return 13; + case 183: return 17; + case 188: return 8; + case 189: return 8; + case 190: return 8; + case 191: return 8; + case 192: return 8; + case 193: return 8; + case 194: return 8; + case 195: return 8; + case 196: return 8; + case 197: return 8; + case 198: return 8; + case 199: return 8; + case 200: return 8; + case 201: return 8; + case 202: return 8; + case 206: return 2; + case 215: return 11; + case 1816: return 12; + default: return 22; + } } Index: PC/generrmap.c =================================================================== --- PC/generrmap.c (revision 83626) +++ PC/generrmap.c (working copy) @@ -1,6 +1,160 @@ #include #include +/* MSVCRT provides it's own implementation (can only be linked statically) */ +#ifndef _MSC_VER +#include +/* + * This source file was copied from PostgreSQL sources and is subject + * to the copyright below. + */ +/*------------------------------------------------------------------------- + * + * win32error.c + * Map win32 error codes to errno values + * + * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $ + * + *------------------------------------------------------------------------- + */ +/* +PostgreSQL Database Management System +(formerly known as Postgres, then as Postgres95) + +Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group + +Portions Copyright (c) 1994, The Regents of the University of California + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this +paragraph and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS +DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO +PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +*/ + +static const struct { + DWORD winerr; + int doserr; +} doserrors[] = +{ + { ERROR_INVALID_FUNCTION, EINVAL }, + { ERROR_FILE_NOT_FOUND, ENOENT }, + { ERROR_PATH_NOT_FOUND, ENOENT }, + { ERROR_TOO_MANY_OPEN_FILES, EMFILE }, + { ERROR_ACCESS_DENIED, EACCES }, + { ERROR_INVALID_HANDLE, EBADF }, + { ERROR_ARENA_TRASHED, ENOMEM }, + { ERROR_NOT_ENOUGH_MEMORY, ENOMEM }, + { ERROR_INVALID_BLOCK, ENOMEM }, + { ERROR_BAD_ENVIRONMENT, E2BIG }, + { ERROR_BAD_FORMAT, ENOEXEC }, + { ERROR_INVALID_ACCESS, EINVAL }, + { ERROR_INVALID_DATA, EINVAL }, + { ERROR_INVALID_DRIVE, ENOENT }, + { ERROR_CURRENT_DIRECTORY, EACCES }, + { ERROR_NOT_SAME_DEVICE, EXDEV }, + { ERROR_NO_MORE_FILES, ENOENT }, + { ERROR_WRITE_PROTECT, EACCES }, + { ERROR_BAD_UNIT, EACCES }, + { ERROR_NOT_READY, EACCES }, + { ERROR_BAD_COMMAND, EACCES }, + { ERROR_CRC, EACCES }, + { ERROR_BAD_LENGTH, EACCES }, + { ERROR_SEEK, EACCES }, + { ERROR_NOT_DOS_DISK, EACCES }, + { ERROR_SECTOR_NOT_FOUND, EACCES }, + { ERROR_OUT_OF_PAPER, EACCES }, + { ERROR_WRITE_FAULT, EACCES }, + { ERROR_READ_FAULT, EACCES }, + { ERROR_GEN_FAILURE, EACCES }, + { ERROR_SHARING_VIOLATION, EACCES }, + { ERROR_LOCK_VIOLATION, EACCES }, + { ERROR_SHARING_VIOLATION, EACCES }, + { ERROR_WRONG_DISK, EACCES }, + { ERROR_WRONG_DISK + 1, EACCES }, + { ERROR_SHARING_BUFFER_EXCEEDED, EACCES }, + { ERROR_BAD_NETPATH, ENOENT }, + { ERROR_NETWORK_ACCESS_DENIED, EACCES }, + { ERROR_BAD_NET_NAME, ENOENT }, + { ERROR_FILE_EXISTS, EEXIST }, + { ERROR_CANNOT_MAKE, EACCES }, + { ERROR_FAIL_I24, EACCES }, + { ERROR_NO_PROC_SLOTS, EAGAIN }, + { ERROR_DRIVE_LOCKED, EACCES }, + { ERROR_BROKEN_PIPE, EPIPE }, + { ERROR_DISK_FULL, ENOSPC }, + { ERROR_INVALID_TARGET_HANDLE, EBADF }, + { ERROR_INVALID_HANDLE, EINVAL }, + { ERROR_WAIT_NO_CHILDREN, ECHILD }, + { ERROR_CHILD_NOT_COMPLETE, ECHILD }, + { ERROR_DIRECT_ACCESS_HANDLE, EBADF }, + { ERROR_SEEK_ON_DEVICE, EACCES }, + { ERROR_DIR_NOT_EMPTY, ENOTEMPTY }, + { ERROR_NOT_LOCKED, EACCES }, + { ERROR_BAD_PATHNAME, ENOENT }, + { ERROR_MAX_THRDS_REACHED, EAGAIN }, + { ERROR_LOCK_FAILED, EACCES }, + { ERROR_ALREADY_EXISTS, EEXIST }, + { ERROR_INVALID_STARTING_CODESEG, ENOEXEC }, + { ERROR_INVALID_STACKSEG, ENOEXEC }, + { ERROR_INVALID_MODULETYPE, ENOEXEC }, + { ERROR_INVALID_EXE_SIGNATURE, ENOEXEC }, + { ERROR_EXE_MARKED_INVALID, ENOEXEC }, + { ERROR_BAD_EXE_FORMAT, ENOEXEC }, + { ERROR_ITERATED_DATA_EXCEEDS_64k, ENOEXEC }, + { ERROR_INVALID_MINALLOCSIZE, ENOEXEC }, + { ERROR_DYNLINK_FROM_INVALID_RING, ENOEXEC }, + { ERROR_IOPL_NOT_ENABLED, ENOEXEC }, + { ERROR_INVALID_SEGDPL, ENOEXEC }, + { ERROR_AUTODATASEG_EXCEEDS_64k, ENOEXEC }, + { ERROR_RING2SEG_MUST_BE_MOVABLE, ENOEXEC }, + { ERROR_RELOC_CHAIN_XEEDS_SEGLIM, ENOEXEC }, + { ERROR_INFLOOP_IN_RELOC_CHAIN, ENOEXEC }, + { ERROR_FILENAME_EXCED_RANGE, ENOENT }, + { ERROR_NESTING_NOT_ALLOWED, EAGAIN }, + { ERROR_NOT_ENOUGH_QUOTA, ENOMEM } +}; + +void +_dosmaperr(unsigned long e) +{ + int i; + + if (e == 0) + { + errno = 0; + return; + } + + for (i = 0; i < (sizeof(doserrors) / sizeof(*doserrors)); i++) + { + if (doserrors[i].winerr == e) + { + errno = doserrors[i].doserr; + return; + } + } + + /* fprintf(stderr, "unrecognized win32 error code: %lu", e); */ + errno = EINVAL; + return; +} +#endif + /* Extract the mapping of Win32 error codes to errno */ int main() @@ -15,6 +169,7 @@ continue; printf("\t\tcase %d: return %d;\n", i, errno); } - printf("\t\tdefault: return EINVAL;\n"); + printf("\t\tdefault: return %d;\n", EINVAL); printf("\t}\n}\n"); } + Index: Lib/distutils/spawn.py =================================================================== --- Lib/distutils/spawn.py (revision 83626) +++ Lib/distutils/spawn.py (working copy) @@ -33,7 +33,7 @@ if os.name == 'posix': _spawn_posix(cmd, search_path, dry_run=dry_run) elif os.name == 'nt': - _spawn_nt(cmd, search_path, dry_run=dry_run) + _spawn_nt(cmd, search_path, dry_run=dry_run, system='msys' in sys.builtin_module_names) elif os.name == 'os2': _spawn_os2(cmd, search_path, dry_run=dry_run) else: @@ -56,25 +56,34 @@ args[i] = '"%s"' % arg return args -def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0): +def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0, system=0): executable = cmd[0] - cmd = _nt_quote_args(cmd) + qcmd = _nt_quote_args(cmd) if search_path: # either we find one or it stays the same executable = find_executable(executable) or executable - log.info(' '.join([executable] + cmd[1:])) + log.info(' '.join([executable] + qcmd[1:])) if not dry_run: # spawn for NT requires a full path to the .exe try: - rc = os.spawnv(os.P_WAIT, executable, cmd) + if system: + if executable == cmd[0]: + rc = os.system("env " + " ".join(qcmd)) + else: + rc = os.system("env " + _nt_quote_args([executable])[0] + " " + " ".join(qcmd[1:])) + else: + rc = os.spawnv(os.P_WAIT, executable, qcmd) except OSError as exc: # this seems to happen when the command isn't found raise DistutilsExecError( - "command '%s' failed: %s" % (cmd[0], exc.args[-1])) + "command '%s' failed: %s" % (qcmd[0], exc.args[-1])) if rc != 0: # and this reflects the command running but failing raise DistutilsExecError( - "command '%s' failed with exit status %d" % (cmd[0], rc)) + "command '%s' failed with exit status %d" % (qcmd[0], rc)) def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0): executable = cmd[0] Index: Lib/distutils/util.py =================================================================== --- Lib/distutils/util.py (revision 83626) +++ Lib/distutils/util.py (working copy) @@ -650,3 +650,19 @@ def run_2to3(self, files): return run_2to3(files, self.fixer_names, self.options, self.explicit) + +def msysize(pathstr): + """Converts an absolute or relative path contained in 'pathstr' from w32 form to msys form.""" + fix_disk = re.sub (r"([A-Za-z]):(?:\\|/)", r"/\1/", pathstr) + fix_seps = re.sub (r'\\', r'/', fix_disk) + escaped = fix_seps + return escaped + Index: Lib/distutils/ccompiler.py =================================================================== --- Lib/distutils/ccompiler.py (revision 83626) +++ Lib/distutils/ccompiler.py (working copy) @@ -948,6 +948,9 @@ osname = os.name if platform is None: platform = sys.platform + if 'msys' in sys.builtin_module_names: + # MSys implies that gcc is used, even though we're on NT + return 'unix' for pattern, compiler in _default_compilers: if re.match(pattern, platform) is not None or \ re.match(pattern, osname) is not None: Index: Lib/distutils/unixccompiler.py =================================================================== --- Lib/distutils/unixccompiler.py (revision 83626) +++ Lib/distutils/unixccompiler.py (working copy) @@ -24,6 +24,7 @@ from distutils.errors import \ DistutilsExecError, CompileError, LibError, LinkError from distutils import log +from distutils.util import msysize # XXX Things not currently handled: # * optimization/debug/warning flags; we just use whatever's in Python's @@ -169,12 +170,18 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): compiler_so = self.compiler_so + if 'msys' in sys.builtin_module_names: + src = msysize(src) + obj = msysize(obj) + cc_args = [msysize(x) for x in cc_args] + extra_postargs = [msysize(x) for x in extra_postargs] if sys.platform == 'darwin': compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) try: @@ -297,7 +304,8 @@ # use it anyway. Since distutils has always passed in # -Wl whenever gcc was used in the past it is probably # safest to keep doing so. - if sysconfig.get_config_var("GNULD") == "yes": + if sysconfig.get_config_var("GNULD") == "yes" and \ + sys.platform != 'win32': # GNU ld needs an extra option to get a RUNPATH # instead of just an RPATH. return "-Wl,--enable-new-dtags,-R" + dir Index: Lib/distutils/command/install.py =================================================================== --- Lib/distutils/command/install.py (revision 83626) +++ Lib/distutils/command/install.py (working copy) @@ -27,7 +27,15 @@ from site import USER_SITE HAS_USER_SITE = True -if sys.version < "2.2": +if 'msys' in sys.builtin_module_names: + WINDOWS_SCHEME = { + 'purelib': '$base/lib/python$py_version_short/site-packages', + 'platlib': '$platbase/lib/python$py_version_short/site-packages', + 'headers': '$base/include/python$py_version_short/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + } +elif sys.version < "2.2": WINDOWS_SCHEME = { 'purelib': '$base', 'platlib': '$base', @@ -79,13 +87,23 @@ # user site schemes if HAS_USER_SITE: - INSTALL_SCHEMES['nt_user'] = { - 'purelib': '$usersite', - 'platlib': '$usersite', - 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', - 'scripts': '$userbase/Scripts', - 'data' : '$userbase', - } + if 'msys' in sys.builtin_module_names: + INSTALL_SCHEMES['nt_user'] = { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/include/python$py_version_short/$dist_name', + 'scripts': '$userbase/bin', + 'data' : '$userbase', + } + else: + INSTALL_SCHEMES['nt_user'] = { + 'purelib': '$usersite', + 'platlib': '$usersite', + 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', + 'scripts': '$userbase/Scripts', + 'data' : '$userbase', + } + INSTALL_SCHEMES['unix_user'] = { 'purelib': '$usersite', Index: Lib/distutils/command/build_ext.py =================================================================== --- Lib/distutils/command/build_ext.py (revision 83626) +++ Lib/distutils/command/build_ext.py (working copy) @@ -12,7 +12,7 @@ from distutils.sysconfig import customize_compiler, get_python_version from distutils.dep_util import newer_group from distutils.extension import Extension -from distutils.util import get_platform +from distutils.util import get_platform, msysize from distutils import log # this keeps compatibility from 2.3 to 2.5 @@ -187,7 +187,7 @@ # for extensions under windows use different directories # for Release and Debug builds. # also Python's library directory must be appended to library_dirs - if os.name == 'nt': + if os.name == 'nt' and 'msys' not in sys.builtin_module_names: # the 'libs' directory is for binary installs - we assume that # must be the *native* platform. But we don't really support # cross-compiling via a binary install anyway, so we let it go. @@ -221,7 +221,44 @@ else: self.library_dirs.append(os.path.join(sys.exec_prefix, 'PC', 'VC6')) + elif os.name == 'nt' and 'msys' in sys.builtin_module_names: + self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs')) + # This is hacky, but there is no other way to find real path to + # mingw directory + os.system ('env gcc -print-search-dirs >buildextgcccallstdout') + gcclibpaths = [] + with open ('buildextgcccallstdout') as stdo: + for line in stdo: + line = line.rstrip ('\r').rstrip ('\n') + if line.startswith ('libraries: ='): + gcclibpaths = line.replace ('libraries: =', '').split (';') + os.system ('env rm -f buildextgcccallstdout') + self.library_dirs.extend (gcclibpaths) + os.system ('env sh -c echo "int main(){return 0;}" | gcc -v -x c - 2>buildextgcccallstdout') + gccincpaths = [] + with open ('buildextgcccallstdout') as stdo: + includequotes = False + includeangles = False + for line in stdo: + line = line.rstrip ('\r').rstrip ('\n') + if line.startswith ('#include "..." search starts here:'): + includequotes = True + includeangles = False + elif line.startswith ('#include <...> search starts here:'): + includeangles = True + includequotes = False + elif line.startswith ('End of search list.'): + break + elif includeangles or includequotes: + gcclibpaths.append (line.lstrip(' ')) + os.system ('env rm -f buildextgcccallstdout') + self.include_dirs.extend (gcclibpaths) + + # Append the source distribution include and library directories, + # this allows distutils on windows to work in the source tree + #self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) + # OS/2 (EMX) doesn't support Debug vs Release builds, but has the # import libraries in its "Config" subdirectory if os.name == 'os2': @@ -502,10 +539,13 @@ for undef in ext.undef_macros: macros.append((undef,)) + output_dir = self.build_temp + include_dirs = ext.include_dirs + objects = self.compiler.compile(sources, - output_dir=self.build_temp, + output_dir=output_dir, macros=macros, - include_dirs=ext.include_dirs, + include_dirs=include_dirs, debug=self.debug, extra_postargs=extra_args, depends=ext.depends) @@ -696,7 +736,14 @@ # pyconfig.h that MSVC groks. The other Windows compilers all seem # to need it mentioned explicitly, though, so that's what we do. # Append '_d' to the python import library on debug builds. - if sys.platform == "win32": + if sys.platform == "win32" and 'msys' in sys.builtin_module_names: + template = "python%d.%d" + pythonlib = (template % + (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) + # don't extend ext.libraries, it may be shared with other + # extensions, it is a reference to the original list + return ext.libraries + [pythonlib] + elif sys.platform == "win32": from distutils.msvccompiler import MSVCCompiler if not isinstance(self.compiler, MSVCCompiler): template = "python%d%d" Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (revision 83626) +++ Lib/distutils/sysconfig.py (working copy) @@ -451,6 +451,13 @@ global _config_vars _config_vars = g +def _init_msys(): + """Initialize the module as appropriate for NT/MSys""" + _init_nt() + _init_posix() + global _config_vars + # _init_posix will set it to '.dll' + _config_vars['SO'] = '.pyd' def _init_nt(): """Initialize the module as appropriate for NT""" @@ -526,7 +533,10 @@ """ global _config_vars if _config_vars is None: - func = globals().get("_init_" + os.name) + if 'msys' in sys.builtin_module_names: + func = globals().get("_init_msys") + else: + func = globals().get("_init_" + os.name) if func: func() else: Index: Lib/sysconfig.py =================================================================== --- Lib/sysconfig.py (revision 83626) +++ Lib/sysconfig.py (working copy) @@ -386,7 +386,7 @@ def get_config_h_filename(): """Returns the path of pyconfig.h.""" if _PYTHON_BUILD: - if os.name == "nt": + if os.name == "nt" and 'msys' not in sys.builtin_module_names: inc_dir = os.path.join(_PROJECT_BASE, "PC") else: inc_dir = _PROJECT_BASE @@ -450,7 +450,7 @@ if os.name in ('nt', 'os2'): _init_non_posix(_CONFIG_VARS) - if os.name == 'posix': + if os.name == 'posix' or 'msys' in sys.builtin_module_names: _init_posix(_CONFIG_VARS) # Setting 'userbase' is done below the call to the # init function to enable using 'get_config_var' in Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (revision 83626) +++ Makefile.pre.in (working copy) @@ -71,6 +71,7 @@ # environment variables PY_CPPFLAGS= -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS) PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS) +NT_LDFLAGS= @NT_LDFLAGS@ LDLAST= @LDLAST@ SGI_ABI= @SGI_ABI@ CCSHARED= @CCSHARED@ @@ -181,6 +182,8 @@ MACHDEP_OBJS= @MACHDEP_OBJS@ LIBOBJDIR= Python/ LIBOBJS= @LIBOBJS@ +FROZEN_MAIN= @FROZEN_MAIN@ +NTOBJS= @NTOBJS@ PYTHON= python$(EXE) BUILDPYTHON= python$(BUILDEXE) @@ -293,7 +296,7 @@ Python/dynamic_annotations.o \ Python/errors.o \ Python/frozen.o \ - Python/frozenmain.o \ + $(FROZEN_MAIN) \ Python/future.o \ Python/getargs.o \ Python/getcompiler.o \ @@ -326,7 +329,8 @@ Python/$(DYNLOADFILE) \ $(LIBOBJS) \ $(MACHDEP_OBJS) \ - $(THREADOBJ) + $(THREADOBJ) \ + $(NTOBJS) ########################################################################## @@ -426,8 +430,8 @@ # Build the shared modules sharedmods: $(BUILDPYTHON) @case $$MAKEFLAGS in \ - *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS) $(NT_LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS) $(NT_LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ esac # Build static library @@ -499,9 +503,10 @@ # This rule builds the Cygwin Python DLL and import library if configured # for a shared core library; otherwise, this rule is a noop. $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS) if test -n "$(DLLLIBRARY)"; then \ - $(LDSHARED) $(PY_LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \ + $(LDSHARED) $(PY_LDFLAGS) -Wl,--export-all-symbols,--out-implib=$(LDLIBRARY) -o $(DLLLIBRARY) $^ \ $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \ else true; \ fi @@ -590,6 +595,18 @@ Python/importdl.o: $(srcdir)/Python/importdl.c $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c +PC/%.o: $(srcdir)/PC/%.c + $(CC) -c $(PY_CORE_CFLAGS) -I$(srcdir)/Python -o $@ $< + +$(srcdir)/PC/generrmap.exe: $(srcdir)/PC/generrmap.o + $(CC) $(PY_CORE_CFLAGS) -o $@ $< + +$(srcdir)/PC/errmap.h: $(srcdir)/PC/generrmap.exe + $(srcdir)/PC/generrmap.exe > $@ + +Objects/exceptions.o: $(srcdir)/Objects/exceptions.c $(srcdir)/PC/errmap.h + $(CC) -c -I$(srcdir)/PC $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Objects/exceptions.c + Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \ $(srcdir)/Objects/unicodetype_db.h @@ -780,7 +797,7 @@ install: altinstall bininstall altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \ - sharedinstall oldsharedinstall maninstall @FRAMEWORKALTINSTALLLAST@ + @SHAREDINSTALL@ oldsharedinstall maninstall @FRAMEWORKALTINSTALLLAST@ # Install shared libraries enabled by Setup DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED) @@ -1050,6 +1067,14 @@ --install-platlib=$(DESTSHARED) \ --root=/$(DESTDIR) +# Same thing, but with \\ prefix for paths - prevents MSys path mangling +msyssharedinstall: sharedmods + $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \ + --prefix=\\$(prefix) \ + --install-scripts=\\$(BINDIR) \ + --install-platlib=\\$(DESTSHARED) \ + --root=/$(DESTDIR) + # Here are a couple of targets for MacOSX again, to install a full # framework-based Python. frameworkinstall installs everything, the # subtargets install specific parts. Much of the actual work is offloaded to @@ -1186,6 +1211,7 @@ find . -name '*.[oa]' -exec rm -f {} ';' find . -name '*.s[ol]' -exec rm -f {} ';' find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';' + find . \( -name '*.exe' -o -name '*.dll' -o -name '*.pyd' \) -exec rm -f {} ';' find build -name 'fficonfig.h' -exec rm -f {} ';' || true find build -name 'fficonfig.py' -exec rm -f {} ';' || true -rm -f Lib/lib2to3/*Grammar*.pickle @@ -1269,7 +1295,7 @@ # Declare targets that aren't real files .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest .PHONY: install altinstall oldsharedinstall bininstall altbininstall -.PHONY: maninstall libinstall inclinstall libainstall sharedinstall +.PHONY: maninstall libinstall inclinstall libainstall sharedinstall msyssharedinstall .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean Index: Modules/makesetup =================================================================== --- Modules/makesetup (revision 83626) +++ Modules/makesetup (working copy) @@ -85,6 +85,13 @@ # Setup to link with extra libraries when makeing shared extensions. # Currently, only Cygwin needs this baggage. case `uname -s` in +MINGW32*) if test $libdir = . + then + ExtraLibDir=. + else + ExtraLibDir='$(LIBPL)' + fi + ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";; CYGWIN*) if test $libdir = . then ExtraLibDir=. Index: Modules/_ctypes/callproc.c =================================================================== --- Modules/_ctypes/callproc.c (revision 83626) +++ Modules/_ctypes/callproc.c (working copy) @@ -760,7 +760,7 @@ int *space; ffi_cif cif; int cc; -#ifdef MS_WIN32 +#ifdef _MSC_VER int delta; #ifndef DONT_USE_SEH DWORD dwExceptionCode = 0; @@ -812,6 +812,8 @@ #ifndef DONT_USE_SEH __try { #endif +#endif +#ifdef _MSC_VER delta = #endif ffi_call(&cif, (void *)pProc, resmem, avalues); @@ -846,6 +848,7 @@ return -1; } #endif +#ifdef _MSC_VER #ifdef MS_WIN64 if (delta != 0) { PyErr_Format(PyExc_RuntimeError, @@ -876,6 +879,7 @@ } #endif #endif +#endif if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred()) return -1; return 0; Index: Modules/_ctypes/_ctypes_test.c =================================================================== --- Modules/_ctypes/_ctypes_test.c (revision 83626) +++ Modules/_ctypes/_ctypes_test.c (working copy) @@ -4,7 +4,11 @@ #include #endif -#if defined(MS_WIN32) || defined(__CYGWIN__) +/* __declspec(dllexport) disables default export-all-symbols functionality + in GNU ld, which is not desirable (PyInit__ctypes_test is not marked + with it) + */ +#if (defined(MS_WIN32) || defined(__CYGWIN__)) && !defined(__MINGW32__) #define EXPORT(x) __declspec(dllexport) x #else #define EXPORT(x) x Index: Modules/getpath.c =================================================================== --- Modules/getpath.c (revision 83626) +++ Modules/getpath.c (working copy) @@ -198,7 +198,7 @@ reduce(wchar_t *dir) { size_t i = wcslen(dir); - while (i > 0 && dir[i] != SEP) + while (i > 0 && dir[i] != SEP && dir[i] != ALTSEP) --i; dir[i] = '\0'; } @@ -522,7 +522,13 @@ } else progpath[0] = '\0'; +#ifdef MS_WINDOWS + if (progpath[0] != '\0' && + !(progpath[1] == L':' && (progpath[0] > L'A' && progpath[0] < L'z'))) +#else if (progpath[0] != SEP && progpath[0] != '\0') +#endif + absolutize(progpath); wcsncpy(argv0_path, progpath, MAXPATHLEN); argv0_path[MAXPATHLEN] = '\0'; Index: Modules/socketmodule.h =================================================================== --- Modules/socketmodule.h (revision 83626) +++ Modules/socketmodule.h (working copy) @@ -20,13 +20,19 @@ * any version information. * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. */ -# ifdef SIO_GET_MULTICAST_FILTER +# if defined(SIO_GET_MULTICAST_FILTER) # include /* for SIO_RCVALL */ # define HAVE_ADDRINFO # define HAVE_SOCKADDR_STORAGE # define HAVE_GETADDRINFO # define HAVE_GETNAMEINFO # define ENABLE_IPV6 +# elif defined(__MINGW32__) +# define HAVE_ADDRINFO +# define HAVE_SOCKADDR_STORAGE +# define HAVE_GETADDRINFO +# define HAVE_GETNAMEINFO +# define ENABLE_IPV6 # else typedef int socklen_t; # endif /* IPPROTO_IPV6 */ Index: Modules/_multiprocessing/semaphore.c =================================================================== --- Modules/_multiprocessing/semaphore.c (revision 83626) +++ Modules/_multiprocessing/semaphore.c (working copy) @@ -494,7 +494,7 @@ static PyObject * semlock_getvalue(SemLockObject *self) { -#ifdef HAVE_BROKEN_SEM_GETVALUE +#if defined(HAVE_BROKEN_SEM_GETVALUE) && !defined(MS_WINDOWS) PyErr_SetNone(PyExc_NotImplementedError); return NULL; #else @@ -512,7 +512,7 @@ static PyObject * semlock_iszero(SemLockObject *self) { -#ifdef HAVE_BROKEN_SEM_GETVALUE +#if defined(HAVE_BROKEN_SEM_GETVALUE) && !defined(MS_WINDOWS) if (sem_trywait(self->handle) < 0) { if (errno == EAGAIN) Py_RETURN_TRUE; Index: Modules/Setup.dist =================================================================== --- Modules/Setup.dist (revision 83626) +++ Modules/Setup.dist (working copy) @@ -91,7 +91,7 @@ TESTPATH= # Path components for machine- or system-dependent modules and shared libraries -MACHDEPPATH=:plat-$(MACHDEP) +MACHDEPPATH=$(MACHDEP_PATH_SEPARATOR)plat-$(MACHDEP) EXTRAMACHDEPPATH= COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH) @@ -105,10 +105,8 @@ # This only contains the minimal set of modules required to run the # setup.py script in the root of the Python source tree. -posix 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 + _sre _sre.c # Fredrik Lundh's new regular expressions _codecs _codecsmodule.c # access to the builtin codecs and codec registry _weakref _weakref.c # weak references Index: Modules/_sqlite/connection.c =================================================================== --- Modules/_sqlite/connection.c (revision 83626) +++ Modules/_sqlite/connection.c (working copy) @@ -1340,7 +1340,7 @@ goto finally; } - module = PyImport_ImportModule(MODULE_NAME ".dump"); + module = PyImport_ImportModule(Py_SQLITE_TO_STRING(MODULE_NAME) ".dump"); if (!module) { goto finally; } @@ -1558,7 +1558,7 @@ PyTypeObject pysqlite_ConnectionType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".Connection", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".Connection", /* tp_name */ sizeof(pysqlite_Connection), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_connection_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/cache.c =================================================================== --- Modules/_sqlite/cache.c (revision 83626) +++ Modules/_sqlite/cache.c (working copy) @@ -276,7 +276,7 @@ PyTypeObject pysqlite_NodeType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME "Node", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) "Node", /* tp_name */ sizeof(pysqlite_Node), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_node_dealloc, /* tp_dealloc */ @@ -318,7 +318,7 @@ PyTypeObject pysqlite_CacheType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".Cache", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".Cache", /* tp_name */ sizeof(pysqlite_Cache), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_cache_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/statement.c =================================================================== --- Modules/_sqlite/statement.c (revision 83626) +++ Modules/_sqlite/statement.c (working copy) @@ -460,7 +460,7 @@ PyTypeObject pysqlite_StatementType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".Statement", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".Statement", /* tp_name */ sizeof(pysqlite_Statement), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_statement_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/row.c =================================================================== --- Modules/_sqlite/row.c (revision 83626) +++ Modules/_sqlite/row.c (working copy) @@ -205,7 +205,7 @@ PyTypeObject pysqlite_RowType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".Row", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".Row", /* tp_name */ sizeof(pysqlite_Row), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_row_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/sqlitecompat.h =================================================================== --- Modules/_sqlite/sqlitecompat.h (revision 83626) +++ Modules/_sqlite/sqlitecompat.h (working copy) @@ -60,4 +60,6 @@ #define Py_TYPE(ob) ((ob)->ob_type) #endif + +#define Py_SQLITE_TO_STRING(a) #a #endif Index: Modules/_sqlite/cursor.c =================================================================== --- Modules/_sqlite/cursor.c (revision 83626) +++ Modules/_sqlite/cursor.c (working copy) @@ -1059,7 +1059,7 @@ PyTypeObject pysqlite_CursorType = { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".Cursor", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".Cursor", /* tp_name */ sizeof(pysqlite_Cursor), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_cursor_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/prepare_protocol.c =================================================================== --- Modules/_sqlite/prepare_protocol.c (revision 83626) +++ Modules/_sqlite/prepare_protocol.c (working copy) @@ -36,7 +36,7 @@ PyTypeObject pysqlite_PrepareProtocolType= { PyVarObject_HEAD_INIT(NULL, 0) - MODULE_NAME ".PrepareProtocol", /* tp_name */ + Py_SQLITE_TO_STRING(MODULE_NAME) ".PrepareProtocol", /* tp_name */ sizeof(pysqlite_PrepareProtocol), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)pysqlite_prepare_protocol_dealloc, /* tp_dealloc */ Index: Modules/_sqlite/module.c =================================================================== --- Modules/_sqlite/module.c (revision 83626) +++ Modules/_sqlite/module.c (working copy) @@ -28,6 +28,7 @@ #include "prepare_protocol.h" #include "microprotocols.h" #include "row.h" +#include "sqlitecompat.h" #if SQLITE_VERSION_NUMBER >= 3003003 #define HAVE_SHARED_CACHE @@ -352,56 +353,56 @@ /*** Create DB-API Exception hierarchy */ - if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) { + if (!(pysqlite_Error = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".Error", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Error", pysqlite_Error); - if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) { + if (!(pysqlite_Warning = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".Warning", PyExc_Exception, NULL))) { goto error; } PyDict_SetItemString(dict, "Warning", pysqlite_Warning); /* Error subclasses */ - if (!(pysqlite_InterfaceError = PyErr_NewException(MODULE_NAME ".InterfaceError", pysqlite_Error, NULL))) { + if (!(pysqlite_InterfaceError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".InterfaceError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "InterfaceError", pysqlite_InterfaceError); - if (!(pysqlite_DatabaseError = PyErr_NewException(MODULE_NAME ".DatabaseError", pysqlite_Error, NULL))) { + if (!(pysqlite_DatabaseError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".DatabaseError", pysqlite_Error, NULL))) { goto error; } PyDict_SetItemString(dict, "DatabaseError", pysqlite_DatabaseError); /* pysqlite_DatabaseError subclasses */ - if (!(pysqlite_InternalError = PyErr_NewException(MODULE_NAME ".InternalError", pysqlite_DatabaseError, NULL))) { + if (!(pysqlite_InternalError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".InternalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "InternalError", pysqlite_InternalError); - if (!(pysqlite_OperationalError = PyErr_NewException(MODULE_NAME ".OperationalError", pysqlite_DatabaseError, NULL))) { + if (!(pysqlite_OperationalError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".OperationalError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "OperationalError", pysqlite_OperationalError); - if (!(pysqlite_ProgrammingError = PyErr_NewException(MODULE_NAME ".ProgrammingError", pysqlite_DatabaseError, NULL))) { + if (!(pysqlite_ProgrammingError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".ProgrammingError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "ProgrammingError", pysqlite_ProgrammingError); - if (!(pysqlite_IntegrityError = PyErr_NewException(MODULE_NAME ".IntegrityError", pysqlite_DatabaseError,NULL))) { + if (!(pysqlite_IntegrityError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".IntegrityError", pysqlite_DatabaseError,NULL))) { goto error; } PyDict_SetItemString(dict, "IntegrityError", pysqlite_IntegrityError); - if (!(pysqlite_DataError = PyErr_NewException(MODULE_NAME ".DataError", pysqlite_DatabaseError, NULL))) { + if (!(pysqlite_DataError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".DataError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "DataError", pysqlite_DataError); - if (!(pysqlite_NotSupportedError = PyErr_NewException(MODULE_NAME ".NotSupportedError", pysqlite_DatabaseError, NULL))) { + if (!(pysqlite_NotSupportedError = PyErr_NewException(Py_SQLITE_TO_STRING(MODULE_NAME) ".NotSupportedError", pysqlite_DatabaseError, NULL))) { goto error; } PyDict_SetItemString(dict, "NotSupportedError", pysqlite_NotSupportedError); @@ -466,7 +467,7 @@ error: if (PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, MODULE_NAME ": init failed"); + PyErr_SetString(PyExc_ImportError, Py_SQLITE_TO_STRING(MODULE_NAME) ": init failed"); Py_DECREF(module); module = NULL; } Index: Modules/python.c =================================================================== --- Modules/python.c (revision 83626) +++ Modules/python.c (working copy) @@ -7,7 +7,7 @@ #include #endif -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) && !defined(__MINGW32__) int wmain(int argc, wchar_t **argv) { Index: Modules/Setup.config.in =================================================================== --- Modules/Setup.config.in (revision 83626) +++ Modules/Setup.config.in (working copy) @@ -9,5 +9,25 @@ # The signal module @USE_SIGNAL_MODULE@signal signalmodule.c +# posix (UNIX) system calls +@USE_POSIX_MODULE@posix posixmodule.c +# posix (UNIX) system calls +@USE_NT_MODULE@nt posixmodule.c +# dummy MSys module - it is a hack that tells Python (by placing "msys" into +# _names) that it is built in Msys and thus can use some POSIX stuff at +# setup time +@USE_MSYS_MODULE@msys msysmodule.c + +# this is needed to find out the user's home dir +# if $HOME is not set +@USE_PWD_MODULE@pwd pwdmodule.c + +# On Windows this is needed for 'locales' to be imported in 'site' +@USE__COLLECTIONS_MODULE@_collections _collectionsmodule.c # Container types +@USE__COLLECTIONS_MODULE@operator operator.c # operator.add() and similar goodies +@USE__COLLECTIONS_MODULE@itertools itertoolsmodule.c # Functions creating iterators for efficient looping + +MACHDEP_PATH_SEPARATOR=@MACHDEP_PATH_SEPARATOR@ + # The rest of the modules previously listed in this file are built # by the setup.py script in Python 2.1 and later. Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 83626) +++ Modules/posixmodule.c (working copy) @@ -129,7 +129,7 @@ #define HAVE_FSYNC 1 #define fsync _commit #else -#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS) +#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS) || defined(MS_WINDOWS) /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */ #else /* all other compilers */ /* Unix functions that the configure script doesn't check for */ @@ -252,7 +252,7 @@ #endif #endif -#ifdef _MSC_VER +#ifdef MS_WINDOWS #ifdef HAVE_DIRECT_H #include #endif @@ -275,7 +275,11 @@ #include #include #include /* for ShellExecute() */ -#endif /* _MSC_VER */ +#ifdef __MINGW32__ +#include /* for FSCTL_GET_REPARSE_POINT */ +#include /* for HCRYPTPROV */ +#endif +#endif /* MS_WINDOWS */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) #include @@ -894,7 +898,7 @@ int st_ctime_nsec; }; -static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */ +static __int64 secs_between_epochs = 11644473600LL; /* Seconds between 1.1.1601 and 1.1.1970 */ static void FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out) @@ -4989,6 +4993,7 @@ "readlink(path) -> path\n\n\ Return a string representing the path to which the symbolic link points."); +#ifndef __MINGW32__ /* The following structure was copied from http://msdn.microsoft.com/en-us/library/ms791514.aspx as the required include doesn't seem to be present in the Windows SDK (at least as included @@ -5021,10 +5026,12 @@ }; } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; + #define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER,\ GenericReparseBuffer) #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) +#endif /* Windows readlink implementation */ static PyObject * @@ -8189,7 +8196,7 @@ } -#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) +#if (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) #define INITFUNC PyInit_nt #define MODNAME "nt" Index: Modules/main.c =================================================================== --- Modules/main.c (revision 83626) +++ Modules/main.c (working copy) @@ -14,9 +14,11 @@ #include #ifdef HAVE_FCNTL_H #include +#ifndef PATH_MAX #define PATH_MAX MAXPATHLEN #endif #endif +#endif #ifdef _MSC_VER #include