New version of my patch. Addresses some issues i've found since the last one. Diff against a recent trunk is attached.
Changes (relative to previous patch):
Python/pythonrun.c:
* Added a call to _set_abort_behavior(). That should fix http://bugs.python.org/issue9116Python/dynamic_annotations.c:
* Changed _MSC_VER to MS_WINDOWS, since the code does not seem to be MSVC-specific
configure.in:
* Added AC_DEFINE for Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE (for MSVC-based builds it is hardcoded in PC/pyconfig.h)
* Added -no-undefined LDFLAG for Windows builds - helps find missing library dependencies at buildtime
* Added -fno-common and -mms-bitfields CFLAGS for Windows builds. -fno-common could fix some hidden problem with aligned commons, and -mms-bitfields should improve compatibility with MSVC-built binaries
* Added -D_GNU_SOURCE CFLAG. Defining this enables MinGW non-ANSI extensions, including the custom printf() implementation that supports %z format
* Added AC_DEFINE for HAVE_GETPEERNAME, because testing lws2_32 for it is tricky
* Removed PY_FORMAT_SIZE_T fiddling, since with GNU extensions %z is supported
setup.py:
* _subprocess module is now built on win32 to support subprocess extension
* msvcrt, winreg and winsound modules are built as well
PC/winreg.c:
* Added REG_LEGAL_CHANGE_FILTER definition (MinGW does not define it)
PC/dl_nt.c:
* Fixed PFN_ADDREFACTCTX and PFN_RELEASEACTCTX - according to MSDN, they return nothing
* Fixed the way AddRefActCtx is called (GetLastError() is being checked for errors instead of return value)
PC/generrmap.c:
* Added return 0 to prevent generrmap.exe from "failing" (returning something other than 0)
PC/msvcrtmodule.c:
* Added #ifdef guards around crtdbg.h, because only MSVC provides it
Lib/site.py:
* Extended os.sep == '/' (why isn't os.name tested?) to msys
* Extended addbuilddir calling condition to msys
Lib/distutils/sysconfig.py:
* Extended some posix conditions to msys, restricted some nt conditions to non-msys
Lib/distutils/tests/test_bdist_msi.py:
* Disabled this test for MSys (MinGW can't build msi module)
Lib/distutils/ccompiler.py:
* An extra hack to add $(srcdir) to library_dirs at build time
Lib/distutils/sysconfig.py:
* Some MSys-specific configuration magic
Lib/ntpath.py:
* Added a reminder that realpath() can now be implemented
Lib/sysconfig.py:
* Added msys-only variation of directory layout (copied from posix)
Lib/test/test_site.py:
* Widened os.sep == '/' condition to MSys
Makefile.pre.in:
* Fixed CFLAGS order for Objects/exceptions.o target (won't include pyconfig.h from PC anymore)
Modules/getpath.c:
* Massive fixes. Most thigs are copied from PC/getpathp.c (who had the bright idea of having two separate, but almost identical headers?)
* Ripped a readlink() implementation from posixmodule.c to use here. By the way, it was buggy, so i had to fix it as well.
Modules/socketmodule.h:
* Added some definitions for MinGW - these aren't in current MinGW w32api package, and will (probably) never get there.
Modules/_multiprocessing/win32_functions.c:
Modules/_multiprocessing/multiprocessing.h:
* Added more gurads on crtdbg stuff, because it is MSVC-only
Modules/selectmodule.c:
* Changed some guards from _MSC_VER to MS_WINDOWS, because the code is not MSVC-specific
Modules/posixmodule.c:
* Changed some guards to work for MinGW as well
* Discovered why i previously had to fix mkdir() call. Now that's not necessary anymore (but i left previous fix as it is, can't hurt to be careful)
I ran some tests and tried to make my Python build pass them, which partially fueled my bugfixing efforts.
_ctypes test (namely - test_callconv_1) crashes the interpreter (SIGSEGV in libffi), so i had to comment it out.
test_capi fails (but that should be now fixed in MSVC builds, can't test it in a MinGW build)
test_cmath fails (i have no idea why)
test_cmd_line fails (i think it is not adapted to MSys; and i'm not sure it needs to be - after all, this Python build is NOT intended to be ran in MSys most of the time)
test_distutils fails (i've fixed that only partially)
test_email fails (wrong crlfs)
test_format fails (?)
test_heapq fails (but when i re-run it, it passes; because of pre-compilation?)
test_platform fails (doesn't work well with symlinked python, because realpath isn't implemented on NT yet)
test_smtplib fails (no idea - why)
test_sundry fails (?)
test_sysconfig fails (didn't try to fix)
test_tarfile fails (didn't try to fix)
test_tcl fails (didn't try to fix)
test_trace (didn't try to fix)
test_urllib2 (didn't try to fix)
test_multiprocessing is skipped because there's no test for multiprocessing in Lib/test/
282 tests OK.