summary refs log tree commit diff
path: root/pkgs/development/interpreters/python
diff options
context:
space:
mode:
authorFlorian Friesdorf <flo@chaoflow.net>2014-10-23 21:25:57 +0200
committerRok Garbas <rok@garbas.si>2015-05-28 10:53:36 +0200
commit5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e (patch)
tree24d39a5b8778bebaccba798c4eee9782b2df3852 /pkgs/development/interpreters/python
parentd2da94cc0bd8555b99bc54e2654208b5eeb54d94 (diff)
downloadnixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar.gz
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar.bz2
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar.lz
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar.xz
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.tar.zst
nixlib-5f4a9c3391bad23ffbb3e0a3b740115b7ebee11e.zip
cygwin: python-2.7
Diffstat (limited to 'pkgs/development/interpreters/python')
-rw-r--r--pkgs/development/interpreters/python/2.7/2.5.2-ctypes-util-find_library.patch34
-rw-r--r--pkgs/development/interpreters/python/2.7/2.5.2-tkinter-x11.patch27
-rw-r--r--pkgs/development/interpreters/python/2.7/2.6.2-ssl-threads.patch13
-rw-r--r--pkgs/development/interpreters/python/2.7/2.6.5-FD_SETSIZE.patch41
-rw-r--r--pkgs/development/interpreters/python/2.7/2.6.5-export-PySignal_SetWakeupFd.patch11
-rw-r--r--pkgs/development/interpreters/python/2.7/2.6.5-ncurses-abi6.patch16
-rw-r--r--pkgs/development/interpreters/python/2.7/2.7.3-dbm.patch27
-rw-r--r--pkgs/development/interpreters/python/2.7/2.7.3-dylib.patch10
-rw-r--r--pkgs/development/interpreters/python/2.7/2.7.3-getpath-exe-extension.patch31
-rw-r--r--pkgs/development/interpreters/python/2.7/2.7.3-no-libm.patch11
-rw-r--r--pkgs/development/interpreters/python/2.7/2.7.5-export-PyNode_SizeOf.patch13
-rw-r--r--pkgs/development/interpreters/python/2.7/default.nix45
12 files changed, 268 insertions, 11 deletions
diff --git a/pkgs/development/interpreters/python/2.7/2.5.2-ctypes-util-find_library.patch b/pkgs/development/interpreters/python/2.7/2.5.2-ctypes-util-find_library.patch
new file mode 100644
index 000000000000..22bc0f7ced0a
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.5.2-ctypes-util-find_library.patch
@@ -0,0 +1,34 @@
+--- origsrc/Lib/ctypes/util.py	2007-09-14 15:05:26.000000000 -0500
++++ src/Lib/ctypes/util.py	2008-11-25 17:54:47.319296200 -0600
+@@ -41,6 +41,20 @@
+                 continue
+         return None
+ 
++elif sys.platform == "cygwin":
++    def find_library(name):
++        for libdir in ['/usr/lib', '/usr/local/lib']:
++            for libext in ['lib%s.dll.a' % name, 'lib%s.a' % name]:
++                implib = os.path.join(libdir, libext)
++                if not os.path.exists(implib):
++                    continue
++                cmd = "dlltool -I " + implib + " 2>/dev/null"
++                res = os.popen(cmd).read().replace("\n","")
++                if not res:
++                    continue
++                return res
++        return None
++
+ elif os.name == "posix":
+     # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
+     import re, tempfile, errno
+@@ -157,6 +173,10 @@
+             print cdll.LoadLibrary("libcrypto.dylib")
+             print cdll.LoadLibrary("libSystem.dylib")
+             print cdll.LoadLibrary("System.framework/System")
++        elif sys.platform == "cygwin":
++            print cdll.LoadLibrary("cygbz2-1.dll") 
++            print find_library("crypt")
++            print cdll.LoadLibrary("cygcrypt-0.dll") 
+         else:
+             print cdll.LoadLibrary("libm.so")
+             print cdll.LoadLibrary("libcrypt.so")
diff --git a/pkgs/development/interpreters/python/2.7/2.5.2-tkinter-x11.patch b/pkgs/development/interpreters/python/2.7/2.5.2-tkinter-x11.patch
new file mode 100644
index 000000000000..28b6dafc3f15
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.5.2-tkinter-x11.patch
@@ -0,0 +1,27 @@
+--- origsrc/setup.py	2008-02-04 17:41:02.000000000 -0600
++++ src/setup.py	2008-07-02 02:11:28.671875000 -0500
+@@ -1277,12 +1279,6 @@
+             include_dirs.append('/usr/X11/include')
+             added_lib_dirs.append('/usr/X11/lib')
+ 
+-        # If Cygwin, then verify that X is installed before proceeding
+-        if host_platform == 'cygwin':
+-            x11_inc = find_file('X11/Xlib.h', [], include_dirs)
+-            if x11_inc is None:
+-                return
+-
+         # Check for BLT extension
+         if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
+                                            'BLT8.0'):
+@@ -1300,9 +1296,8 @@
+         if host_platform in ['aix3', 'aix4']:
+             libs.append('ld')
+ 
+-        # Finally, link with the X11 libraries (not appropriate on cygwin)
+-        if host_platform != "cygwin":
+-            libs.append('X11')
++        # Finally, link with the X11 libraries
++        libs.append('X11')
+ 
+         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
+                         define_macros=[('WITH_APPINIT', 1)] + defs,
diff --git a/pkgs/development/interpreters/python/2.7/2.6.2-ssl-threads.patch b/pkgs/development/interpreters/python/2.7/2.6.2-ssl-threads.patch
new file mode 100644
index 000000000000..bef137efda7b
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.6.2-ssl-threads.patch
@@ -0,0 +1,13 @@
+--- origsrc/Modules/_ssl.c	2009-01-26 10:55:41.000000000 -0600
++++ src/Modules/_ssl.c	2009-08-20 00:04:59.346816700 -0500
+@@ -15,6 +15,10 @@
+ 
+ #include "Python.h"
+ 
++#ifdef __CYGWIN__
++#undef WITH_THREAD
++#endif
++
+ #ifdef WITH_THREAD
+ #include "pythread.h"
+ #define PySSL_BEGIN_ALLOW_THREADS { \
diff --git a/pkgs/development/interpreters/python/2.7/2.6.5-FD_SETSIZE.patch b/pkgs/development/interpreters/python/2.7/2.6.5-FD_SETSIZE.patch
new file mode 100644
index 000000000000..d1dae8c47dc1
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.6.5-FD_SETSIZE.patch
@@ -0,0 +1,41 @@
+--- Python-2.6.5.orig/Modules/selectmodule.c	2012-02-02 22:35:21.835125000 -0500
++++ Python-2.6.5/Modules/selectmodule.c	2012-02-02 22:41:41.210125000 -0500
+@@ -6,6 +6,21 @@
+    >= 0.
+ */
+ 
++/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
++   64 is too small (too many people have bumped into that limit).
++   Here we boost it.
++
++   Cygwin also defines FD_SETSIZE to 64, so also increase the limit on
++   Cygwin.  We must do this before sys/types.h is included, which otherwise
++   sets FD_SETSIZE to the default.
++
++   Users who want even more than the boosted limit should #define
++   FD_SETSIZE higher before this; e.g., via compiler /D switch.
++*/
++#if (defined(MS_WINDOWS) || defined(__CYGWIN__)) && !defined(FD_SETSIZE)
++#define FD_SETSIZE 512
++#endif
++
+ #include "Python.h"
+ #include <structmember.h>
+ 
+@@ -16,16 +31,6 @@
+ #undef HAVE_BROKEN_POLL
+ #endif
+ 
+-/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
+-   64 is too small (too many people have bumped into that limit).
+-   Here we boost it.
+-   Users who want even more than the boosted limit should #define
+-   FD_SETSIZE higher before this; e.g., via compiler /D switch.
+-*/
+-#if defined(MS_WINDOWS) && !defined(FD_SETSIZE)
+-#define FD_SETSIZE 512
+-#endif
+-
+ #if defined(HAVE_POLL_H)
+ #include <poll.h>
+ #elif defined(HAVE_SYS_POLL_H)
diff --git a/pkgs/development/interpreters/python/2.7/2.6.5-export-PySignal_SetWakeupFd.patch b/pkgs/development/interpreters/python/2.7/2.6.5-export-PySignal_SetWakeupFd.patch
new file mode 100644
index 000000000000..ea696978236a
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.6.5-export-PySignal_SetWakeupFd.patch
@@ -0,0 +1,11 @@
+--- origsrc/Include/pyerrors.h	2008-06-08 23:58:54.000000000 -0500
++++ src/Include/pyerrors.h	2010-05-12 04:19:31.535297200 -0500
+@@ -232,7 +232,7 @@ PyAPI_FUNC(int) PyErr_CheckSignals(void)
+ PyAPI_FUNC(void) PyErr_SetInterrupt(void);
+ 
+ /* In signalmodule.c */
+-int PySignal_SetWakeupFd(int fd);
++PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd);
+ 
+ /* Support for adding program text to SyntaxErrors */
+ PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
diff --git a/pkgs/development/interpreters/python/2.7/2.6.5-ncurses-abi6.patch b/pkgs/development/interpreters/python/2.7/2.6.5-ncurses-abi6.patch
new file mode 100644
index 000000000000..e1cf5ad4bbf9
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.6.5-ncurses-abi6.patch
@@ -0,0 +1,16 @@
+--- origsrc/Include/py_curses.h	2009-09-06 16:23:05.000000000 -0500
++++ src/Include/py_curses.h	2010-04-14 15:21:23.008971400 -0500
+@@ -17,6 +17,13 @@
+ #define NCURSES_OPAQUE 0
+ #endif /* __APPLE__ */
+ 
++#ifdef __CYGWIN__
++/* the following define is necessary for Cygwin; without it, the
++   Cygwin-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
++   can't get at the WINDOW flags field. */
++#define NCURSES_INTERNALS
++#endif /* __CYGWIN__ */
++
+ #ifdef __FreeBSD__
+ /*
+ ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
diff --git a/pkgs/development/interpreters/python/2.7/2.7.3-dbm.patch b/pkgs/development/interpreters/python/2.7/2.7.3-dbm.patch
new file mode 100644
index 000000000000..bfaeb37c287d
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.7.3-dbm.patch
@@ -0,0 +1,27 @@
+--- origsrc/setup.py.orig	2012-11-27 10:20:47.442395900 -0500
++++ src/setup.py	2012-11-27 10:53:15.583020900 -0500
+@@ -1141,7 +1141,7 @@
+ 
+         dbm_order = ['gdbm']
+         # The standard Unix dbm module:
+-        if host_platform not in ['cygwin']:
++        if host_platform not in ['win32']:
+             config_args = [arg.strip("'")
+                            for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
+             dbm_args = [arg for arg in config_args
+@@ -1192,6 +1192,15 @@
+                                     ],
+                                 libraries = gdbm_libs)
+                             break
++                        if find_file("ndbm.h", inc_dirs, []) is not None:
++                            print("building dbm using gdbm")
++                            dbmext = Extension(
++                                'dbm', ['dbmmodule.c'],
++                                define_macros=[
++                                    ('HAVE_NDBM_H', None),
++                                    ],
++                                libraries = gdbm_libs)
++                            break
+                 elif cand == "bdb":
+                     if db_incs is not None:
+                         print "building dbm using bdb"
diff --git a/pkgs/development/interpreters/python/2.7/2.7.3-dylib.patch b/pkgs/development/interpreters/python/2.7/2.7.3-dylib.patch
new file mode 100644
index 000000000000..6e1fc8b53e83
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.7.3-dylib.patch
@@ -0,0 +1,10 @@
+--- origsrc/Lib/distutils/unixccompiler.py.orig	2012-11-27 07:44:15.409993500 -0500
++++ src/Lib/distutils/unixccompiler.py	2012-11-27 08:09:57.801770900 -0500
+@@ -141,6 +141,7 @@
+     static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
+     if sys.platform == "cygwin":
+         exe_extension = ".exe"
++        dylib_lib_extension = ".dll.a"
+ 
+     def preprocess(self, source,
+                    output_file=None, macros=None, include_dirs=None,
diff --git a/pkgs/development/interpreters/python/2.7/2.7.3-getpath-exe-extension.patch b/pkgs/development/interpreters/python/2.7/2.7.3-getpath-exe-extension.patch
new file mode 100644
index 000000000000..68f6921ba6aa
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.7.3-getpath-exe-extension.patch
@@ -0,0 +1,31 @@
+--- origsrc/Modules/getpath.c.orig	2012-11-27 12:07:56.098645900 -0500
++++ src/Modules/getpath.c	2012-11-27 12:10:11.254895900 -0500
+@@ -436,6 +436,28 @@
+                         if (isxfile(progpath))
+                                 break;
+ 
++#ifdef __CYGWIN__
++                        /*
++                         * Cygwin automatically removes the ".exe" extension from argv[0]
++                         * to make programs feel like they are in a more Unix-like
++                         * environment.  Unfortunately, this can make it problemmatic for
++                         * Cygwin to distinguish between a directory and an executable with
++                         * the same name excluding the ".exe" extension.  For example, the
++                         * Cygwin Python build directory has a "Python" directory and a
++                         * "python.exe" executable.  This causes isxfile() to erroneously
++                         * return false.  If isdir() returns true and there is enough space
++                         * to append the ".exe" extension, then we try again with the
++                         * extension appended.
++                         */
++#define EXE ".exe"
++                        if (isdir(progpath) && strlen(progpath) + strlen(EXE) <= MAXPATHLEN)
++                        {
++                            strcat(progpath, EXE);
++                            if (isxfile(progpath))
++                                break;
++                        }
++#endif /* __CYGWIN__ */
++
+                         if (!delim) {
+                                 progpath[0] = '\0';
+                                 break;
diff --git a/pkgs/development/interpreters/python/2.7/2.7.3-no-libm.patch b/pkgs/development/interpreters/python/2.7/2.7.3-no-libm.patch
new file mode 100644
index 000000000000..55281db6768f
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.7.3-no-libm.patch
@@ -0,0 +1,11 @@
+--- origsrc/setup.py.orig	2012-11-27 09:28:34.051770900 -0500
++++ src/setup.py	2012-11-27 09:28:47.239270900 -0500
+@@ -470,7 +470,7 @@
+ 
+         # Check for MacOS X, which doesn't need libm.a at all
+         math_libs = ['m']
+-        if host_platform in ['darwin', 'beos']:
++        if host_platform in ['darwin', 'beos', 'cygwin']:
+             math_libs = []
+ 
+         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
diff --git a/pkgs/development/interpreters/python/2.7/2.7.5-export-PyNode_SizeOf.patch b/pkgs/development/interpreters/python/2.7/2.7.5-export-PyNode_SizeOf.patch
new file mode 100644
index 000000000000..e5efd6266902
--- /dev/null
+++ b/pkgs/development/interpreters/python/2.7/2.7.5-export-PyNode_SizeOf.patch
@@ -0,0 +1,13 @@
+For the parser extension
+
+--- origsrc/Include/node.h	2013-05-11 22:32:41.000000000 -0500
++++ src/Include/node.h	2013-06-04 02:55:03.949347500 -0500
+@@ -21,7 +21,7 @@ PyAPI_FUNC(int) PyNode_AddChild(node *n,
+                                       char *str, int lineno, int col_offset);
+ PyAPI_FUNC(void) PyNode_Free(node *n);
+ #ifndef Py_LIMITED_API
+-Py_ssize_t _PyNode_SizeOf(node *n);
++PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
+ #endif
+ 
+ /* Node access functions */
diff --git a/pkgs/development/interpreters/python/2.7/default.nix b/pkgs/development/interpreters/python/2.7/default.nix
index 2b9e3c3736ba..eebd4514571e 100644
--- a/pkgs/development/interpreters/python/2.7/default.nix
+++ b/pkgs/development/interpreters/python/2.7/default.nix
@@ -7,6 +7,7 @@
 
 , tcl ? null, tk ? null, x11 ? null, libX11 ? null, x11Support ? true
 , zlib ? null, zlibSupport ? true
+, expat, libffi
 }:
 
 assert zlibSupport -> zlib != null;
@@ -39,6 +40,18 @@ let
       # patch python to put zero timestamp into pyc
       # if DETERMINISTIC_BUILD env var is set
       ./deterministic-build.patch
+    ] ++ optionals stdenv.isCygwin [
+      ./2.5.2-ctypes-util-find_library.patch
+      ./2.5.2-tkinter-x11.patch
+      ./2.6.2-ssl-threads.patch
+      ./2.6.5-export-PySignal_SetWakeupFd.patch
+      ./2.6.5-FD_SETSIZE.patch
+      ./2.6.5-ncurses-abi6.patch
+      ./2.7.3-dbm.patch
+      ./2.7.3-dylib.patch
+      ./2.7.3-getpath-exe-extension.patch
+      ./2.7.3-no-libm.patch
+      ./2.7.5-export-PyNode_SizeOf.patch
     ];
 
   preConfigure = ''
@@ -50,19 +63,26 @@ let
       for i in Lib/plat-*/regen; do
         substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
       done
-    '' + optionalString stdenv.isCygwin ''
-      # On Cygwin, `make install' tries to read this Makefile.
-      mkdir -p $out/lib/python${majorVersion}/config
-      touch $out/lib/python${majorVersion}/config/Makefile
-      mkdir -p $out/include/python${majorVersion}
-      touch $out/include/python${majorVersion}/pyconfig.h
     '';
 
-  configureFlags = "--enable-shared --with-threads --enable-unicode=ucs4";
+  configureFlags = [
+    "--enable-shared"
+    "--with-threads"
+    "--enable-unicode=ucs4"
+  ] ++ optionals stdenv.isCygwin [
+    "--with-system-ffi"
+    "--with-system-expat"
+    "ac_cv_func_bind_textdomain_codeset=yes"
+  ];
+
+  postConfigure = if stdenv.isCygwin then ''
+    sed -i Makefile -e 's,PYTHONPATH="$(srcdir),PYTHONPATH="$(abs_srcdir),'
+  '' else null;
 
   buildInputs =
     optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
     [ bzip2 openssl ]
+    ++ optionals stdenv.isCygwin [ expat libffi ]
     ++ optionals includeModules (
         [ db gdbm ncurses sqlite readline
         ] ++ optionals x11Support [ tcl tk x11 libX11 ]
@@ -150,14 +170,17 @@ let
     if includeModules then null else stdenv.mkDerivation rec {
       name = "python-${moduleName}-${python.version}";
 
-      inherit src patches preConfigure configureFlags;
+      inherit src patches preConfigure postConfigure configureFlags;
 
       buildInputs = [ python ] ++ deps;
 
       C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
       LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
 
-      buildPhase = ''
+      # non-python gdbm has a libintl dependency on i686-cygwin, not on x86_64-cygwin
+      buildPhase = (if (stdenv.system == "i686-cygwin" && moduleName == "gdbm") then ''
+          sed -i setup.py -e "s:libraries = \['gdbm'\]:libraries = ['gdbm', 'intl']:"
+      '' else '''') + ''
           substituteInPlace setup.py --replace 'self.extensions = extensions' \
             'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]'
 
@@ -212,10 +235,10 @@ let
 
   } // optionalAttrs x11Support {
 
-    tkinter = buildInternalPythonModule {
+    tkinter = if stdenv.isCygwin then null else (buildInternalPythonModule {
       moduleName = "tkinter";
       deps = [ tcl tk x11 libX11 ];
-    };
+    });
 
   } // {