Some patches to prevent an error that would occur on Cygwin trying to call
`ldd` on the .dll.a import library for readline, which doesn't work (we
might consider later updating this with a call to dlltool instead, which is
the appropriate alternative).

Also adds the correct link flags for curses on Cygwin.
--- a/setup.py	2017-03-20 17:39:35.351935000 +0100
+++ b/setup.py	2017-03-20 18:16:33.670791400 +0100
@@ -719,7 +719,8 @@
         if not os.path.exists(self.build_temp):
             os.makedirs(self.build_temp)
         # Determine if readline is already linked against curses or tinfo.
-        if do_readline:
+        # This doesn't work properly on Cygwin
+        if do_readline and host_platform != 'cygwin':
             if cross_compiling:
                 ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \
                                 % (sysconfig.get_config_var('READELF'),
@@ -1371,6 +1371,9 @@
 
         if curses_library.startswith('ncurses'):
             curses_libs = [curses_library]
+            if host_platform == 'cygwin':
+                curses_libs.append('tinfo' +
+                                   'w' if curses_library[-1] == 'w' else '')
             exts.append( Extension('_curses', ['_cursesmodule.c'],
                                    include_dirs=curses_includes,
                                    define_macros=curses_defines,
