Skip to content

Instantly share code, notes, and snippets.

@7shi
Created May 1, 2012 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/2568924 to your computer and use it in GitHub Desktop.
Save 7shi/2568924 to your computer and use it in GitHub Desktop.
Python-2.7.3をMSYSでビルドするパッチ(不完全)
diff -ur Python-2.7.3.orig/Modules/posixmodule.c Python-2.7.3/Modules/posixmodule.c
--- Python-2.7.3.orig/Modules/posixmodule.c 2012-04-10 08:07:34 +0900
+++ Python-2.7.3/Modules/posixmodule.c 2012-05-01 22:56:44 +0900
@@ -32,6 +32,19 @@
# include <unixio.h>
#endif /* defined(__VMS) */
+#ifdef MS_WINDOWS
+#include <windows.h>
+#ifndef _MSC_VER
+#define _MSC_VER 0
+#endif
+#ifndef _MAX_ENV
+#define _MAX_ENV 32767
+#endif
+#ifdef HAVE_DEV_PTMX
+#undef HAVE_DEV_PTMX
+#endif
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -9252,8 +9265,8 @@
#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
-#define INITFUNC initnt
-#define MODNAME "nt"
+#define INITFUNC initposix
+#define MODNAME "posix"
#elif defined(PYOS_OS2)
#define INITFUNC initos2
diff -ur Python-2.7.3.orig/Modules/pwdmodule.c Python-2.7.3/Modules/pwdmodule.c
--- Python-2.7.3.orig/Modules/pwdmodule.c 2012-04-10 08:07:34 +0900
+++ Python-2.7.3/Modules/pwdmodule.c 2012-05-01 22:40:18 +0900
@@ -5,7 +5,9 @@
#include "structseq.h"
#include <sys/types.h>
+#ifndef MS_WINDOWS
#include <pwd.h>
+#endif
static PyStructSequence_Field struct_pwd_type_fields[] = {
{"pw_name", "user name"},
@@ -67,6 +69,7 @@
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
#define SETS(i,val) sets(v, i, val)
+#ifndef MS_WINDOWS
SETS(setIndex++, p->pw_name);
#ifdef __VMS
SETS(setIndex++, "");
@@ -82,6 +85,15 @@
#endif
SETS(setIndex++, p->pw_dir);
SETS(setIndex++, p->pw_shell);
+#else
+ SETS(setIndex++, "");
+ SETS(setIndex++, "");
+ SETI(setIndex++, 0);
+ SETI(setIndex++, 0);
+ SETS(setIndex++, "");
+ SETS(setIndex++, "");
+ SETS(setIndex++, "");
+#endif
#undef SETS
#undef SETI
@@ -107,11 +119,13 @@
struct passwd *p;
if (!PyArg_ParseTuple(args, "I:getpwuid", &uid))
return NULL;
+#ifndef MS_WINDOWS
if ((p = getpwuid(uid)) == NULL) {
PyErr_Format(PyExc_KeyError,
"getpwuid(): uid not found: %d", uid);
return NULL;
}
+#endif
return mkpwent(p);
}
@@ -128,11 +142,13 @@
struct passwd *p;
if (!PyArg_ParseTuple(args, "s:getpwnam", &name))
return NULL;
+#ifndef MS_WINDOWS
if ((p = getpwnam(name)) == NULL) {
PyErr_Format(PyExc_KeyError,
"getpwnam(): name not found: %s", name);
return NULL;
}
+#endif
return mkpwent(p);
}
diff -ur Python-2.7.3.orig/Objects/unicodeobject.c Python-2.7.3/Objects/unicodeobject.c
--- Python-2.7.3.orig/Objects/unicodeobject.c 2012-04-10 08:07:34 +0900
+++ Python-2.7.3/Objects/unicodeobject.c 2012-05-01 21:22:05 +0900
@@ -47,6 +47,8 @@
#ifdef MS_WINDOWS
#include <windows.h>
+PyObject *PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors);
+PyObject *PyUnicode_AsMBCSString(PyObject *unicode);
#endif
/* Limit for the Unicode object free list */
diff -ur Python-2.7.3.orig/Python/random.c Python-2.7.3/Python/random.c
--- Python-2.7.3.orig/Python/random.c 2012-04-10 08:07:35 +0900
+++ Python-2.7.3/Python/random.c 2012-05-01 21:23:30 +0900
@@ -1,6 +1,7 @@
#include "Python.h"
#ifdef MS_WINDOWS
#include <windows.h>
+#include <wincrypt.h>
#else
#include <fcntl.h>
#endif
diff -ur Python-2.7.3.orig/configure Python-2.7.3/configure
--- Python-2.7.3.orig/configure 2012-04-10 08:07:36 +0900
+++ Python-2.7.3/configure 2012-05-01 22:27:29 +0900
@@ -11132,7 +11132,7 @@
else
case " $LIBOBJS " in
*" fileblocks.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS fileblocks.$ac_objext"
+ *) #LIBOBJS="$LIBOBJS fileblocks.$ac_objext"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment