Skip to content

Commit 18de7ac

Browse files
committed
Fix the nt module
1 parent 18d4975 commit 18de7ac

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ endif(UNIX AND NOT APPLE)
7777
# Add extension modules
7878
set(builtin_extensions "" CACHE INTERNAL "" FORCE)
7979
set(builtin_source "" CACHE INTERNAL "" FORCE)
80+
set(builtin_link_libraries "" CACHE INTERNAL "" FORCE)
8081
set(extensions_enabled "" CACHE INTERNAL "" FORCE)
8182
set(extensions_disabled "" CACHE INTERNAL "" FORCE)
8283
add_subdirectory(cmake/extensions)

cmake/Extensions.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ function(add_python_extension name)
6262
# This will be compiled into libpython instead of as a separate library
6363
set(builtin_extensions "${builtin_extensions}${name};" CACHE INTERNAL "" FORCE)
6464
set(builtin_source "${builtin_source}${absolute_sources};" CACHE INTERNAL "" FORCE)
65+
set(builtin_link_libraries "${builtin_link_libraries}${ADD_PYTHON_EXTENSION_LIBRARIES};" CACHE INTERNAL "" FORCE)
66+
elseif(WIN32 AND NOT ENABLE_SHARED)
67+
# Extensions cannot be built against a static libpython on windows
6568
else(BUILTIN_${upper_name})
6669
add_library(${target_name} SHARED ${absolute_sources})
6770
include_directories(${ADD_PYTHON_EXTENSION_INCLUDEDIRS})

cmake/extensions/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ add_python_extension(termios REQUIRES UNIX SOURCES termios.c)
8585
add_python_extension(linuxaudiodev REQUIRES LINUX SOURCES linuxaudiodev.c)
8686
add_python_extension(ossaudiodev REQUIRES LINUX SOURCES ossaudiodev.c)
8787

88+
# Windows-only extensions
89+
add_python_extension(nt REQUIRES WIN32 BUILTIN SOURCES posixmodule.c)
90+
8891
# Multiprocessing is different on unix and windows
8992
if(UNIX)
9093
add_python_extension(_multiprocessing

cmake/libpython/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ endforeach(ext)
155155
function (add_libpython name type)
156156
add_library(${name} ${type} ${LIBPYTHON_SOURCES})
157157
target_link_libraries(${name}
158+
${builtin_link_libraries}
158159
${CMAKE_THREAD_LIBS_INIT}
159160
dl
160161
m

cmake/patches-win32/03-mingw32.patch

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
--- /home/david/Python-2.7.1/Modules/posixmodule.c 2010-11-26 17:35:50.000000000 +0000
2+
+++ Modules/posixmodule.c 2011-01-29 16:13:03.000000000 +0000
3+
@@ -133,7 +133,20 @@
4+
#else
5+
#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
6+
/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
7+
-#else /* all other compilers */
8+
+#else
9+
+#if defined(__MINGW32__)
10+
+#define HAVE_EXECV 1
11+
+#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
12+
+#define HAVE_FORK1 1
13+
+#endif
14+
+#define HAVE_GETCWD 1
15+
+#define HAVE_OPENDIR 1
16+
+#define HAVE_PIPE 1
17+
+#ifndef __rtems__
18+
+#define HAVE_POPEN 1
19+
+#endif
20+
+#define HAVE_SYSTEM 1
21+
+#else /* all other compilers */
22+
/* Unix functions that the configure script doesn't check for */
23+
#define HAVE_EXECV 1
24+
#define HAVE_FORK 1
25+
@@ -155,13 +168,14 @@
26+
#define HAVE_SYSTEM 1
27+
#define HAVE_WAIT 1
28+
#define HAVE_TTYNAME 1
29+
+#endif /* __MINGW32__ */
30+
#endif /* PYOS_OS2 && PYCC_GCC && __VMS */
31+
#endif /* _MSC_VER */
32+
#endif /* __BORLANDC__ */
33+
#endif /* ! __WATCOMC__ || __QNX__ */
34+
#endif /* ! __IBMC__ */
35+
36+
-#ifndef _MSC_VER
37+
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
38+
39+
#if defined(__sgi)&&_COMPILER_VERSION>=700
40+
/* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode
41+
@@ -213,7 +227,7 @@
42+
#endif /* HAVE_LSTAT */
43+
#endif /* !HAVE_UNISTD_H */
44+
45+
-#endif /* !_MSC_VER */
46+
+#endif /* !_MSC_VER && !__MINGW32__ */
47+
48+
#ifdef HAVE_UTIME_H
49+
#include <utime.h>
50+
@@ -258,7 +272,7 @@
51+
#endif
52+
#endif
53+
54+
-#ifdef _MSC_VER
55+
+#if defined(_MSC_VER) || defined(__MINGW32__)
56+
#ifdef HAVE_DIRECT_H
57+
#include <direct.h>
58+
#endif
59+
@@ -274,7 +288,7 @@
60+
#include <shellapi.h> /* for ShellExecute() */
61+
#define popen _popen
62+
#define pclose _pclose
63+
-#endif /* _MSC_VER */
64+
+#endif /* _MSC_VER || __MINGW32__ */
65+
66+
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
67+
#include <io.h>
68+
@@ -8452,7 +8466,7 @@
69+
}
70+
#endif
71+
72+
-#ifdef MS_WINDOWS
73+
+#if defined(MS_WINDOWS) && !defined(__MINGW32__)
74+
75+
PyDoc_STRVAR(win32_urandom__doc__,
76+
"urandom(n) -> str\n\n\
77+
@@ -8948,7 +8962,7 @@
78+
#ifdef HAVE_GETLOADAVG
79+
{"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
80+
#endif
81+
- #ifdef MS_WINDOWS
82+
+ #if defined(MS_WINDOWS) && !defined(__MINGW32__)
83+
{"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
84+
#endif
85+
#ifdef __VMS
86+
@@ -9252,7 +9266,7 @@
87+
}
88+
89+
90+
-#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
91+
+#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) && !defined(__QNX__)
92+
#define INITFUNC initnt
93+
#define MODNAME "nt"
94+
95+
--- /home/david/Python-2.7.1/PC/pyconfig.h 2009-10-24 14:28:38.000000000 +0100
96+
+++ PC/pyconfig.h 2011-01-29 16:03:17.000000000 +0000
97+
@@ -227,6 +227,12 @@
98+
#include <basetsd.h>
99+
#endif
100+
101+
+
102+
+#ifdef __MINGW32__
103+
+# define HAVE_DIRENT_H
104+
+#endif // __MINGW32__
105+
+
106+
+
107+
/* ------------------------------------------------------------------------*/
108+
/* The Borland compiler defines __BORLANDC__ */
109+
/* XXX These defines are likely incomplete, but should be easy to fix. */

0 commit comments

Comments
 (0)