Skip to content

Commit f541e3d

Browse files
committed
add a --with-system-expat option to build pyexpat against the system's lib #7609
1 parent 25425d0 commit f541e3d

4 files changed

Lines changed: 61 additions & 27 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ C-API
9393
Build
9494
-----
9595

96+
- Issue #7609: Add a --with-system-expat option that causes the system's expat
97+
library to be used for the pyexpat module instead of the one included with
98+
Python.
99+
96100
- Issue #7589: Only build the nis module when the correct header files are
97101
found.
98102

configure

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 76644 .
2+
# From configure.in Revision: 77031 .
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.61 for python 2.7.
55
#
@@ -1348,6 +1348,8 @@ Optional Packages:
13481348
--with-suffix=.exe set executable suffix
13491349
--with-pydebug build with Py_DEBUG defined
13501350
--with-libs='lib1 ...' link against additional libs
1351+
--with-system-expat build pyexpat module using an installed expat
1352+
library
13511353
--with-system-ffi build _ctypes module using an installed ffi library
13521354
--with-dbmliborder=db1:db2:...
13531355
order to check db backends for dbm. Valid value is a
@@ -3857,7 +3859,7 @@ else
38573859
{ echo "$as_me:$LINENO: result: no" >&5
38583860
echo "${ECHO_T}no" >&6; }
38593861
fi
3860-
rm -f -r conftest*
3862+
rm -f conftest*
38613863

38623864

38633865

@@ -5410,7 +5412,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
54105412
else
54115413
ac_cv_header_stdc=no
54125414
fi
5413-
rm -f -r conftest*
5415+
rm -f conftest*
54145416

54155417
fi
54165418

@@ -5431,7 +5433,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
54315433
else
54325434
ac_cv_header_stdc=no
54335435
fi
5434-
rm -f -r conftest*
5436+
rm -f conftest*
54355437

54365438
fi
54375439

@@ -6529,7 +6531,7 @@ _ACEOF
65296531

65306532

65316533
fi
6532-
rm -f -r conftest*
6534+
rm -f conftest*
65336535

65346536
{ echo "$as_me:$LINENO: result: $was_it_defined" >&5
65356537
echo "${ECHO_T}$was_it_defined" >&6; }
@@ -7059,7 +7061,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
70597061
else
70607062
ac_cv_type_uid_t=no
70617063
fi
7062-
rm -f -r conftest*
7064+
rm -f conftest*
70637065

70647066
fi
70657067
{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
@@ -15513,6 +15515,19 @@ echo "${ECHO_T}no" >&6; }
1551315515
fi
1551415516

1551515517

15518+
# Check for use of the system expat library
15519+
{ echo "$as_me:$LINENO: checking for --with-system-expat" >&5
15520+
echo $ECHO_N "checking for --with-system-expat... $ECHO_C" >&6; }
15521+
15522+
# Check whether --with-system_expat was given.
15523+
if test "${with_system_expat+set}" = set; then
15524+
withval=$with_system_expat;
15525+
fi
15526+
15527+
15528+
{ echo "$as_me:$LINENO: result: $with_system_expat" >&5
15529+
echo "${ECHO_T}$with_system_expat" >&6; }
15530+
1551615531
# Check for use of the system libffi library
1551715532
{ echo "$as_me:$LINENO: checking for --with-system-ffi" >&5
1551815533
echo $ECHO_N "checking for --with-system-ffi... $ECHO_C" >&6; }
@@ -15719,7 +15734,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1571915734
else
1572015735
unistd_defines_pthreads=no
1572115736
fi
15722-
rm -f -r conftest*
15737+
rm -f conftest*
1572315738

1572415739
{ echo "$as_me:$LINENO: result: $unistd_defines_pthreads" >&5
1572515740
echo "${ECHO_T}$unistd_defines_pthreads" >&6; }
@@ -17333,7 +17348,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1733317348
$EGREP "yes" >/dev/null 2>&1; then
1733417349
ipv6type=$i
1733517350
fi
17336-
rm -f -r conftest*
17351+
rm -f conftest*
1733717352

1733817353
;;
1733917354
kame)
@@ -17356,7 +17371,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1735617371
ipv6libdir=/usr/local/v6/lib
1735717372
ipv6trylibc=yes
1735817373
fi
17359-
rm -f -r conftest*
17374+
rm -f conftest*
1736017375

1736117376
;;
1736217377
linux-glibc)
@@ -17377,7 +17392,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1737717392
ipv6type=$i;
1737817393
ipv6trylibc=yes
1737917394
fi
17380-
rm -f -r conftest*
17395+
rm -f conftest*
1738117396

1738217397
;;
1738317398
linux-inet6)
@@ -17415,7 +17430,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1741517430
ipv6lib=inet6;
1741617431
ipv6libdir=/usr/local/v6/lib
1741717432
fi
17418-
rm -f -r conftest*
17433+
rm -f conftest*
1741917434

1742017435
;;
1742117436
v6d)
@@ -17438,7 +17453,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1743817453
ipv6libdir=/usr/local/v6/lib;
1743917454
BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"
1744017455
fi
17441-
rm -f -r conftest*
17456+
rm -f conftest*
1744217457

1744317458
;;
1744417459
zeta)
@@ -17460,7 +17475,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1746017475
ipv6lib=inet6;
1746117476
ipv6libdir=/usr/local/v6/lib
1746217477
fi
17463-
rm -f -r conftest*
17478+
rm -f conftest*
1746417479

1746517480
;;
1746617481
esac
@@ -26003,7 +26018,7 @@ cat >>confdefs.h <<\_ACEOF
2600326018
_ACEOF
2600426019

2600526020
fi
26006-
rm -f -r conftest*
26021+
rm -f conftest*
2600726022

2600826023
cat >conftest.$ac_ext <<_ACEOF
2600926024
/* confdefs.h. */
@@ -26022,7 +26037,7 @@ cat >>confdefs.h <<\_ACEOF
2602226037
_ACEOF
2602326038

2602426039
fi
26025-
rm -f -r conftest*
26040+
rm -f conftest*
2602626041

2602726042
fi
2602826043

@@ -26292,7 +26307,7 @@ cat >>confdefs.h <<\_ACEOF
2629226307
_ACEOF
2629326308

2629426309
fi
26295-
rm -f -r conftest*
26310+
rm -f conftest*
2629626311

2629726312
fi
2629826313

configure.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,13 @@ LIBS="$withval $LIBS"
19641964
],
19651965
[AC_MSG_RESULT(no)])
19661966

1967+
# Check for use of the system expat library
1968+
AC_MSG_CHECKING(for --with-system-expat)
1969+
AC_ARG_WITH(system_expat,
1970+
AC_HELP_STRING(--with-system-expat, build pyexpat module using an installed expat library))
1971+
1972+
AC_MSG_RESULT($with_system_expat)
1973+
19671974
# Check for use of the system libffi library
19681975
AC_MSG_CHECKING(for --with-system-ffi)
19691976
AC_ARG_WITH(system_ffi,

setup.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,19 +1220,26 @@ class db_found(Exception): pass
12201220
#
12211221
# More information on Expat can be found at www.libexpat.org.
12221222
#
1223-
expatinc = os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')
1224-
define_macros = [
1225-
('HAVE_EXPAT_CONFIG_H', '1'),
1226-
]
1223+
if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
1224+
expat_inc = []
1225+
define_macros = []
1226+
expat_lib = ['expat']
1227+
expat_sources = []
1228+
else:
1229+
expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')]
1230+
define_macros = [
1231+
('HAVE_EXPAT_CONFIG_H', '1'),
1232+
]
1233+
expat_lib = []
1234+
expat_sources = ['expat/xmlparse.c',
1235+
'expat/xmlrole.c',
1236+
'expat/xmltok.c']
12271237

12281238
exts.append(Extension('pyexpat',
12291239
define_macros = define_macros,
1230-
include_dirs = [expatinc],
1231-
sources = ['pyexpat.c',
1232-
'expat/xmlparse.c',
1233-
'expat/xmlrole.c',
1234-
'expat/xmltok.c',
1235-
],
1240+
include_dirs = expat_inc,
1241+
libraries = expat_lib,
1242+
sources = ['pyexpat.c'] + expat_sources
12361243
))
12371244

12381245
# Fredrik Lundh's cElementTree module. Note that this also
@@ -1242,7 +1249,8 @@ class db_found(Exception): pass
12421249
define_macros.append(('USE_PYEXPAT_CAPI', None))
12431250
exts.append(Extension('_elementtree',
12441251
define_macros = define_macros,
1245-
include_dirs = [expatinc],
1252+
include_dirs = expat_inc,
1253+
libraries = expat_lib,
12461254
sources = ['_elementtree.c'],
12471255
))
12481256
else:

0 commit comments

Comments
 (0)