Previously, I had submitted the Cygwin Python DLL and Shared Extension Patch which was accepted and committed into Python CVS. This patch builds Python with a DLL core (instead of a static library) just like the native Win32 version. Once Cygwin Python has a DLL core, the standard modules can be built as shared libraries (i.e., DLLs) and extension modules can be built using either the traditional Modules/Makefile.pre or Distutils methods. Hence, Cygwin Python now supports shared extensions identical to other UNIX platforms. If you are interested in the gory details, then please see the following: http://sourceforge.net/patch/?func=detailpatch&patch_id=102409&group_id=5470 Unfortunately when the Python build was changed to use Distutils instead of the traditional method to build the standard modules, this broke the build for Cygwin. The attached patch (re)enables Python 2.1a1 to build OOTB under Cygwin. I am in the process of getting the relevant portions of this patch accepted into Python CVS. Hopefully, Cygwin Python will build OOTB from 2.1a2 on. The procedure to build Cygwin Python 2.1a1 under Cygwin 1.1.7 is as follows: $ wget -nd http://download.sourceforge.net/python/Python-2.1a1.tgz $ # save attached patch to /tmp/Cygwin-1.1.7-Python-2.1a1.patch $ tar -xvzf Python-2.1a1.tgz $ cd Python-2.1a1 $ patch -p0 </tmp/Cygwin-1.1.7-Python-2.1a1.patch $ configure --with-threads=no --with-libm= --with-suffix=.exe --with-check-import-case $ make A few notes about the patch: 1. The Modules/syslogmodule.c part is unnecessary if you are building against the current Cygwin CVS or later. 2. The Python/import.c part is a hack and will never been accepted into Python CVS, but it is a quick and dirty way to get Cygwin Python to deal with modules that differ only by case. For example, the following from getpass.getpass() will fail: import termios, TERMIOS without this part of the patch. I intend to submit patches to correct the above issue "the right way" by 2.1a2. Unfortunately, this will be a lot of work. Sigh... The curious may also be interested in the following: http://sourceforge.net/patch/?func=detailpatch&patch_id=103154&group_id=5470 http://sourceforge.net/patch/?func=detailpatch&patch_id=103220&group_id=5470 Any feedback on the issues raised in the above would be greatly appreciated. Thanks, Jason -- Jason Tishler Director, Software Engineering Phone: +1 (732) 264-8770 x235 Dot Hill Systems Corp. Fax: +1 (732) 264-8798 82 Bethany Road, Suite 7 Email: [EMAIL PROTECTED] Hazlet, NJ 07730 USA WWW: http://www.dothill.com
Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.113 diff -u -r1.113 Makefile.in --- Makefile.in 2001/01/23 01:53:09 1.113 +++ Makefile.in 2001/01/23 18:26:30 @@ -428,7 +428,7 @@ # Install the dynamically loadable modules # This goes into $(exec_prefix) sharedinstall: - ./python$(EXE) $(srcdir)/setup.py install + ./python$(EXE) $(srcdir)/setup.py install +--install-platlib=$(DESTSHARED) # Old rules for installing shared modules built using makesetup oldsharedinstall: cd Modules; $(MAKE) \ Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.12 diff -u -r1.12 setup.py --- setup.py 2001/01/22 10:38:27 1.12 +++ setup.py 2001/01/23 18:26:32 @@ -259,11 +259,12 @@ # similar functionality (but slower of course) implemented in Python. # The standard Unix dbm module: - if (self.compiler.find_library_file(lib_dirs, 'ndbm')): - exts.append( Extension('dbm', ['dbmmodule.c'], - libraries = ['ndbm'] ) ) - else: - exts.append( Extension('dbm', ['dbmmodule.c']) ) + if sys.platform[:6] not in ['cygwin']: + if (self.compiler.find_library_file(lib_dirs, 'ndbm')): + exts.append( Extension('dbm', ['dbmmodule.c'], + libraries = ['ndbm'] ) ) + else: + exts.append( Extension('dbm', ['dbmmodule.c']) ) # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: if (self.compiler.find_library_file(lib_dirs, 'gdbm')): @@ -316,7 +317,8 @@ # Steen Lumholt's termios module exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface - exts.append( Extension('resource', ['resource.c']) ) + if sys.platform[:6] not in ['cygwin']: + exts.append( Extension('resource', ['resource.c']) ) if (self.compiler.find_library_file(lib_dirs, 'nsl')): exts.append( Extension('nis', ['nismodule.c'], Index: Lib/distutils/command/build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.69 diff -u -r1.69 build_ext.py --- Lib/distutils/command/build_ext.py 2001/01/09 03:15:47 1.69 +++ Lib/distutils/command/build_ext.py 2001/01/23 18:26:43 @@ -163,6 +163,17 @@ self.build_temp = os.path.join(self.build_temp, "Debug") else: self.build_temp = os.path.join(self.build_temp, "Release") + + # for extensions under Cygwin the Python's library directory must be + # appended to library_dirs + if sys.platform[:6] == 'cygwin': + if string.find(sys.executable, sys.exec_prefix) != -1: + # building third party extensions + self.library_dirs.append(os.path.join(sys.prefix, "lib", "python" + +sys.version[:3], "config")) + else: + # building python standard extensions + self.library_dirs.append('.') + # finalize_options () @@ -571,6 +582,13 @@ template = "python%d%d" if self.debug: template = template + '_d' + pythonlib = (template % + (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) + # don't extend ext.libraries, it may be shared with other + # extensions, it is a reference to the original list + return ext.libraries + [pythonlib] + elif sys.platform[:6] == "cygwin": + template = "python%d.%d" pythonlib = (template % (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) # don't extend ext.libraries, it may be shared with other Index: Modules/syslogmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/syslogmodule.c,v retrieving revision 2.17 diff -u -r2.17 syslogmodule.c --- Modules/syslogmodule.c 2000/09/01 09:01:32 2.17 +++ Modules/syslogmodule.c 2001/01/23 18:26:45 @@ -115,7 +115,11 @@ if (!PyArg_ParseTuple(args, "l;mask for priority", &maskpri)) return NULL; +#ifdef __CYGWIN__ + omaskpri = 0; +#else omaskpri = setlogmask(maskpri); +#endif return PyInt_FromLong(omaskpri); } Index: Python/import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.156 diff -u -r2.156 import.c --- Python/import.c 2001/01/18 03:03:16 2.156 +++ Python/import.c 2001/01/23 18:26:46 @@ -832,6 +832,9 @@ #ifdef CHECK_IMPORT_CASE static int check_case(char *, int, int, char *); +#ifdef __CYGWIN__ +static int cyg_check_case(char *buf, char *name, int namelen); +#endif /* __CYGWIN__ */ #endif static int find_init_module(char *); /* Forward */ @@ -965,6 +968,10 @@ strcpy(buf+len, fdp->suffix); if (Py_VerboseFlag > 1) PySys_WriteStderr("# trying %s\n", buf); +#if defined(__CYGWIN__) && defined(CHECK_IMPORT_CASE) + if (cyg_check_case(buf, name, namelen)) + continue; +#endif /* __CYGWIN__ && CHECK_IMPORT_CASE */ fp = fopen(buf, fdp->mode); if (fp != NULL) break; @@ -1063,6 +1070,34 @@ return 0; } return 1; +} + +/* + * cyg_check_case determines if the potential module matches but the name + * case does not. + * + * Returns: + * 1, if the module matches but the name case does not + * 0, otherwise + */ +static int +cyg_check_case(char *buf, char *name, int namelen) +{ + WIN32_FIND_DATA data; + HANDLE h; + char tempbuf[MAX_PATH]; + int status = 0; + + cygwin32_conv_to_win32_path(buf, tempbuf); + h = FindFirstFile(tempbuf, &data); + if (h != INVALID_HANDLE_VALUE) + { + if (strncmp(data.cFileName, name, namelen) != 0) + status = 1; + } + FindClose(h); + + return status; } #endif /* MS_WIN32 */