d65f136
diff -up Python-2.6.2/configure.in.expat Python-2.6.2/configure.in
d65f136
--- Python-2.6.2/configure.in.expat	2010-01-25 21:46:42.700858981 -0500
d65f136
+++ Python-2.6.2/configure.in	2010-01-25 21:46:54.710857387 -0500
d65f136
@@ -1898,6 +1898,13 @@ LIBS="$withval $LIBS"
d65f136
 ],
d65f136
 [AC_MSG_RESULT(no)])
d65f136
 
d65f136
+# Check for use of the system expat library
d65f136
+AC_MSG_CHECKING(for --with-system-expat)
d65f136
+AC_ARG_WITH(system_expat,
d65f136
+            AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
d65f136
+
d65f136
+AC_MSG_RESULT($with_system_expat)
d65f136
+
d65f136
 # Check for use of the system libffi library
d65f136
 AC_MSG_CHECKING(for --with-system-ffi)
d65f136
 AC_ARG_WITH(system_ffi,
d65f136
diff -up Python-2.6.2/setup.py.expat Python-2.6.2/setup.py
d65f136
--- Python-2.6.2/setup.py.expat	2010-01-25 21:46:48.490911125 -0500
d65f136
+++ Python-2.6.2/setup.py	2010-01-25 21:46:54.711857933 -0500
d65f136
@@ -1196,19 +1196,26 @@ class PyBuildExt(build_ext):
d65f136
         #
d65f136
         # More information on Expat can be found at www.libexpat.org.
d65f136
         #
d65f136
-        expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
d65f136
-        define_macros = [
d65f136
-            ('HAVE_EXPAT_CONFIG_H', '1'),
d65f136
-        ]
d65f136
+        if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
d65f136
+            expat_inc = []
d65f136
+            define_macros = []
d65f136
+            expat_lib = ['expat']
d65f136
+            expat_sources = []
d65f136
+        else:
d65f136
+            expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')]
d65f136
+            define_macros = [
d65f136
+                ('HAVE_EXPAT_CONFIG_H', '1'),
d65f136
+            ]
d65f136
+            expat_lib = []
d65f136
+            expat_sources = ['expat/xmlparse.c',
d65f136
+                             'expat/xmlrole.c',
d65f136
+                             'expat/xmltok.c']
d65f136
 
d65f136
         exts.append(Extension('pyexpat',
d65f136
                               define_macros = define_macros,
d65f136
-                              include_dirs = [expatinc],
d65f136
-                              sources = ['pyexpat.c',
d65f136
-                                         'expat/xmlparse.c',
d65f136
-                                         'expat/xmlrole.c',
d65f136
-                                         'expat/xmltok.c',
d65f136
-                                         ],
d65f136
+                              include_dirs = expat_inc,
d65f136
+                              libraries = expat_lib,
d65f136
+                              sources = ['pyexpat.c'] + expat_sources
d65f136
                               ))
d65f136
 
d65f136
         # Fredrik Lundh's cElementTree module.  Note that this also
d65f136
@@ -1218,7 +1225,8 @@ class PyBuildExt(build_ext):
d65f136
             define_macros.append(('USE_PYEXPAT_CAPI', None))
d65f136
             exts.append(Extension('_elementtree',
d65f136
                                   define_macros = define_macros,
d65f136
-                                  include_dirs = [expatinc],
d65f136
+                                  include_dirs = expat_inc,
d65f136
+                                  libraries = expat_lib,
d65f136
                                   sources = ['_elementtree.c'],
d65f136
                                   ))
d65f136
         else: