[Distutils] Creating Shared Extensions with Cygwin DLL Python and Distutils
Jason Tishler
Jason.Tishler@dothill.com
Thu Jan 4 22:17:00 2001
--s1GkIU9aaogUa0PY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Cygwin DLL Python and Distutils work very well together to create
shared extensions. Note that these extensions will only work with
Cygwin DLL Python. They will not work with Win32 Python or Cygwin
Python. However, this combination should facilitate UNIX shared
extension providers with the porting of their modules to Windows.
Cygwin DLL Python is a version of Cygwin Python with its core built as
a DLL similar to Win32 Python. One can easy build Cygwin DLL Python by
using the patches and instructions found at:
http://cygwin.com/ml/cygwin/2000-11/msg00471.html
and
http://sourceforge.net/patch/?func=detailpatch&patch_id=102409&group_id=5470
for Python 2.0 and Python CVS, respectively.
For a simple example see the first attachment. This is the setup.py
that corresponds to the Demo/extend example found in the standard Python
distribution.
For a more realistic example see the second attachment. This is the
setup.py that builds the python-ldap module:
http://sourceforge.net/projects/python-ldap
For the above to build, configure must have already been run and the
attached patch (i.e., third attachment) applied. Note that this patch
is just the same one necessary for the traditional Makefile.pre.in
style build under Cygwin.
Jason
--
Jason Tishler
Director, Software Engineering Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation Fax: +1 (732) 264-8798
82 Bethany Road, Suite 7 Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA WWW: http://www.dothill.com
--s1GkIU9aaogUa0PY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="setup.py"
from distutils.core import setup, Extension
setup(
name = "xx",
version = "1.0",
ext_modules = [
Extension("xx", ["xxmodule.c"],
define_macros=[('USE_DL_IMPORT', None)],
library_dirs=["/usr/local/lib/python2.0/config"],
libraries=["python2.0"])])
--s1GkIU9aaogUa0PY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="setup.py"
from distutils.core import setup, Extension
setup(
name = "ldap",
version = "1.10alpha3",
ext_modules = [
Extension(
"_ldap",
["CIDict.c", "LDAPObject.c", "common.c", "constants.c", "errors.c",
"functions.c", "ldapmodule.c", "linkedlist.c", "message.c",
"template.c", "version.c"],
define_macros=[('USE_DL_IMPORT', None), ('HAVE_CONFIG_H', None),
('LDAP_REFERRALS', None)],
library_dirs=["/usr/local/lib", "/usr/local/lib/python2.0/config"],
libraries=["ldap", "lber", "python2.0"])])
--s1GkIU9aaogUa0PY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Cygwin-python-ldap-1.10alpha3.patch"
diff -upr python-ldap-1.10alpha3.orig/Modules/LDAPObject.c python-ldap-1.10alpha3/Modules/LDAPObject.c
--- python-ldap-1.10alpha3.orig/Modules/LDAPObject.c Mon Aug 14 18:37:37 2000
+++ python-ldap-1.10alpha3/Modules/LDAPObject.c Mon Oct 30 09:22:44 2000
@@ -1789,7 +1789,7 @@ setattr( LDAPObject* self, char* name, P
/* type entry */
PyTypeObject LDAP_Type = {
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
/* see http://www.python.org/doc/FAQ.html#3.24 */
PyObject_HEAD_INIT(NULL)
#else /* ! WIN32 */
diff -upr python-ldap-1.10alpha3.orig/Modules/ldapmodule.c python-ldap-1.10alpha3/Modules/ldapmodule.c
--- python-ldap-1.10alpha3.orig/Modules/ldapmodule.c Thu Jul 27 12:08:58 2000
+++ python-ldap-1.10alpha3/Modules/ldapmodule.c Mon Oct 30 09:35:15 2000
@@ -22,12 +22,12 @@ static PyMethodDef methods[] = {
/* module initialisation */
-void
+DL_EXPORT(void)
init_ldap()
{
PyObject *m, *d;
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
/* See http://www.python.org/doc/FAQ.html#3.24 */
LDAP_Type.ob_type = &PyType_Type;
#endif
diff -upr python-ldap-1.10alpha3.orig/Modules/linkedlist.c python-ldap-1.10alpha3/Modules/linkedlist.c
--- python-ldap-1.10alpha3.orig/Modules/linkedlist.c Sun Aug 13 11:03:25 2000
+++ python-ldap-1.10alpha3/Modules/linkedlist.c Mon Oct 30 09:23:23 2000
@@ -111,7 +111,7 @@ static PySequenceMethods default_methods
};
static PyTypeObject default_type = {
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
/* see http://www.python.org/doc/FAQ.html#3.24 */
PyObject_HEAD_INIT(NULL)
#else /* ! WIN32 */
diff -upr python-ldap-1.10alpha3.orig/Modules/template.c python-ldap-1.10alpha3/Modules/template.c
--- python-ldap-1.10alpha3.orig/Modules/template.c Sun Aug 13 10:57:52 2000
+++ python-ldap-1.10alpha3/Modules/template.c Mon Oct 30 09:31:49 2000
@@ -548,7 +548,7 @@ TemplateItem_setattr(self, attr, value)
}
static PyTypeObject TemplateItem_Type = {
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
PyObject_HEAD_INIT(NULL)
#else /* ! WIN32 */
PyObject_HEAD_INIT(&PyType_Type)
@@ -725,7 +725,7 @@ fprintf(stderr, "TemplateDefault_repr RE
}
static PyTypeObject TemplateDefault_Type = {
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
PyObject_HEAD_INIT(NULL)
#else /* ! WIN32 */
PyObject_HEAD_INIT(&PyType_Type)
@@ -908,7 +908,7 @@ Template_setattr(self, attr, value)
}
static PyTypeObject Template_Type = {
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
PyObject_HEAD_INIT(NULL)
#else /* ! WIN32 */
PyObject_HEAD_INIT(&PyType_Type)
--s1GkIU9aaogUa0PY--