diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index eaf624d8bc579b..5788b446201e5a 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -136,7 +136,7 @@ # # needs -lffi and -ldl -@MODULE__CTYPES_TRUE@_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c +#@MODULE__CTYPES_TRUE@_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c # needs -lncurses, -lncursesw or -lcurses, sometimes -ltermcap #@MODULE__CURSES_TRUE@_curses _cursesmodule.c diff --git a/configure b/configure index 608055d91fac36..8ba76bf8c63f70 100755 --- a/configure +++ b/configure @@ -664,8 +664,6 @@ MODULE__GDBM_FALSE MODULE__GDBM_TRUE MODULE__DECIMAL_FALSE MODULE__DECIMAL_TRUE -MODULE__CTYPES_FALSE -MODULE__CTYPES_TRUE MODULE__CRYPT_FALSE MODULE__CRYPT_TRUE MODULE__BLAKE2_FALSE @@ -830,8 +828,6 @@ LIBMPDEC_INTERNAL LIBMPDEC_LDFLAGS LIBMPDEC_CFLAGS LIBFFI_INCLUDEDIR -LIBFFI_LIBS -LIBFFI_CFLAGS LIBEXPAT_INTERNAL LIBEXPAT_LDFLAGS LIBEXPAT_CFLAGS @@ -1064,8 +1060,6 @@ CPP PROFILE_TASK LIBUUID_CFLAGS LIBUUID_LIBS -LIBFFI_CFLAGS -LIBFFI_LIBS LIBNSL_CFLAGS LIBNSL_LIBS LIBSQLITE3_CFLAGS @@ -1863,9 +1857,6 @@ Some influential environment variables: C compiler flags for LIBUUID, overriding pkg-config LIBUUID_LIBS linker flags for LIBUUID, overriding pkg-config - LIBFFI_CFLAGS - C compiler flags for LIBFFI, overriding pkg-config - LIBFFI_LIBS linker flags for LIBFFI, overriding pkg-config LIBNSL_CFLAGS C compiler flags for LIBNSL, overriding pkg-config LIBNSL_LIBS linker flags for LIBNSL, overriding pkg-config @@ -11410,335 +11401,6 @@ $as_echo "$as_me: WARNING: --with(out)-system-ffi is ignored on this platform" > with_system_ffi="yes" fi -have_libffi=missing -if test "x$with_system_ffi" = xyes; then : - - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBFFI" >&5 -$as_echo_n "checking for LIBFFI... " >&6; } - -if test -n "$LIBFFI_CFLAGS"; then - pkg_cv_LIBFFI_CFLAGS="$LIBFFI_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBFFI_CFLAGS=`$PKG_CONFIG --cflags "libffi" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$LIBFFI_LIBS"; then - pkg_cv_LIBFFI_LIBS="$LIBFFI_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBFFI_LIBS=`$PKG_CONFIG --libs "libffi" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - LIBFFI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libffi" 2>&1` - else - LIBFFI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libffi" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$LIBFFI_PKG_ERRORS" >&5 - - - ac_fn_c_check_header_mongrel "$LINENO" "ffi.h" "ac_cv_header_ffi_h" "$ac_includes_default" -if test "x$ac_cv_header_ffi_h" = xyes; then : - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffi_call in -lffi" >&5 -$as_echo_n "checking for ffi_call in -lffi... " >&6; } -if ${ac_cv_lib_ffi_ffi_call+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lffi $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ffi_call (); -int -main () -{ -return ffi_call (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ffi_ffi_call=yes -else - ac_cv_lib_ffi_ffi_call=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ffi_ffi_call" >&5 -$as_echo "$ac_cv_lib_ffi_ffi_call" >&6; } -if test "x$ac_cv_lib_ffi_ffi_call" = xyes; then : - have_libffi=yes -else - have_libffi=no -fi - - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -fi - - - -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - - ac_fn_c_check_header_mongrel "$LINENO" "ffi.h" "ac_cv_header_ffi_h" "$ac_includes_default" -if test "x$ac_cv_header_ffi_h" = xyes; then : - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffi_call in -lffi" >&5 -$as_echo_n "checking for ffi_call in -lffi... " >&6; } -if ${ac_cv_lib_ffi_ffi_call+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lffi $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ffi_call (); -int -main () -{ -return ffi_call (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ffi_ffi_call=yes -else - ac_cv_lib_ffi_ffi_call=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ffi_ffi_call" >&5 -$as_echo "$ac_cv_lib_ffi_ffi_call" >&6; } -if test "x$ac_cv_lib_ffi_ffi_call" = xyes; then : - have_libffi=yes -else - have_libffi=no -fi - - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -fi - - - -else - LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS - LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - have_libffi=yes -fi - -else - - have_libffi=yes - LIBFFI_CFLAGS="-I\$(srcdir)/Modules/_ctypes/darwin -DUSING_MALLOC_CLOSURE_DOT_C=1 -DMACOSX" - LIBFFI_LIBS= - -fi - -case $LIBS in #( - *-ldl*) : - LIBFFI_LIBS="$LIBFFI_LIBS -ldl" - ;; #( - *) : - ;; -esac - -if test "$with_system_ffi" = yes -a "$have_libffi" = yes; then - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" - LIBS="$LIBFFI_LIBS $LIBS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffi_prep_cif_var in ffi.h" >&5 -$as_echo_n "checking for ffi_prep_cif_var in ffi.h... " >&6; } -if ${ac_cv_ffi_prep_cif_var+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "ffi_prep_cif_var" >/dev/null 2>&1; then : - ac_cv_ffi_prep_cif_var=yes -else - ac_cv_ffi_prep_cif_var=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ffi_prep_cif_var" >&5 -$as_echo "$ac_cv_ffi_prep_cif_var" >&6; } - if test "x$ac_cv_ffi_prep_cif_var" = xyes; then : - - -$as_echo "#define HAVE_FFI_PREP_CIF_VAR 1" >>confdefs.h - - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffi_prep_closure_loc in ffi.h" >&5 -$as_echo_n "checking for ffi_prep_closure_loc in ffi.h... " >&6; } -if ${ac_cv_ffi_prep_closure_loc+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "ffi_prep_closure_loc" >/dev/null 2>&1; then : - ac_cv_ffi_prep_closure_loc=yes -else - ac_cv_ffi_prep_closure_loc=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ffi_prep_closure_loc" >&5 -$as_echo "$ac_cv_ffi_prep_closure_loc" >&6; } - if test "x$ac_cv_ffi_prep_closure_loc" = xyes; then : - - -$as_echo "#define HAVE_FFI_PREP_CLOSURE_LOC 1" >>confdefs.h - - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffi_closure_alloc in ffi.h" >&5 -$as_echo_n "checking for ffi_closure_alloc in ffi.h... " >&6; } -if ${ac_cv_ffi_closure_alloc+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "ffi_closure_alloc" >/dev/null 2>&1; then : - ac_cv_ffi_closure_alloc=yes -else - ac_cv_ffi_closure_alloc=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ffi_closure_alloc" >&5 -$as_echo "$ac_cv_ffi_closure_alloc" >&6; } - if test "x$ac_cv_ffi_closure_alloc" = xyes; then : - - -$as_echo "#define HAVE_FFI_CLOSURE_ALLOC 1" >>confdefs.h - - -fi - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - -fi - - if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" else @@ -23078,42 +22740,6 @@ fi $as_echo "$py_cv_module__crypt" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _ctypes" >&5 -$as_echo_n "checking for stdlib extension module _ctypes... " >&6; } - case $py_stdlib_not_available in #( - *_ctypes*) : - py_cv_module__ctypes=n/a ;; #( - *) : - if true; then : - if test "$have_libffi" = yes; then : - py_cv_module__ctypes=yes -else - py_cv_module__ctypes=missing -fi -else - py_cv_module__ctypes=disabled -fi - ;; -esac - as_fn_append MODULE_BLOCK "MODULE__CTYPES=$py_cv_module__ctypes$as_nl" - if test "x$py_cv_module__ctypes" = xyes; then : - - as_fn_append MODULE_BLOCK "MODULE__CTYPES_CFLAGS=$LIBFFI_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE__CTYPES_LDFLAGS=$LIBFFI_LIBS$as_nl" - -fi - if test "$py_cv_module__ctypes" = yes; then - MODULE__CTYPES_TRUE= - MODULE__CTYPES_FALSE='#' -else - MODULE__CTYPES_TRUE='#' - MODULE__CTYPES_FALSE= -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__ctypes" >&5 -$as_echo "$py_cv_module__ctypes" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _decimal" >&5 $as_echo_n "checking for stdlib extension module _decimal... " >&6; } case $py_stdlib_not_available in #( @@ -23724,7 +23350,7 @@ $as_echo_n "checking for stdlib extension module _ctypes_test... " >&6; } py_cv_module__ctypes_test=n/a ;; #( *) : if test "$TEST_MODULES" = yes; then : - if test "$have_libffi" = yes; then : + if true; then : py_cv_module__ctypes_test=yes else py_cv_module__ctypes_test=missing @@ -23738,7 +23364,7 @@ esac if test "x$py_cv_module__ctypes_test" = xyes; then : - as_fn_append MODULE_BLOCK "MODULE__CTYPES_TEST_LDFLAGS=$LIBM$as_nl" + as_fn_append MODULE_BLOCK "MODULE__CTYPES_TEST_LDFLAGS=-lm$as_nl" fi if test "$py_cv_module__ctypes_test" = yes; then @@ -24162,10 +23788,6 @@ if test -z "${MODULE__CRYPT_TRUE}" && test -z "${MODULE__CRYPT_FALSE}"; then as_fn_error $? "conditional \"MODULE__CRYPT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${MODULE__CTYPES_TRUE}" && test -z "${MODULE__CTYPES_FALSE}"; then - as_fn_error $? "conditional \"MODULE__CTYPES\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 7cc6c0c2f592a0..0905014d25b663 100644 --- a/configure.ac +++ b/configure.ac @@ -3187,60 +3187,6 @@ else with_system_ffi="yes" fi -dnl detect libffi -have_libffi=missing -AS_VAR_IF([with_system_ffi], [yes], [ - PKG_CHECK_MODULES([LIBFFI], [libffi], [have_libffi=yes], [ - AC_CHECK_HEADER([ffi.h], [ - WITH_SAVE_ENV([ - AC_CHECK_LIB([ffi], [ffi_call], [have_libffi=yes], [have_libffi=no]) - ]) - ]) - ]) -], [ - dnl private ffi copy - have_libffi=yes - LIBFFI_CFLAGS="-I\$(srcdir)/Modules/_ctypes/darwin -DUSING_MALLOC_CLOSURE_DOT_C=1 -DMACOSX" - LIBFFI_LIBS= -]) - -dnl _ctypes needs -ldl for dlopen -AS_CASE([$LIBS], - [*-ldl*], [LIBFFI_LIBS="$LIBFFI_LIBS -ldl"] -) - -if test "$with_system_ffi" = yes -a "$have_libffi" = yes; then - WITH_SAVE_ENV([ - CFLAGS="$LIBFFI_CFLAGS $CFLAGS" - LIBS="$LIBFFI_LIBS $LIBS" - - AC_CACHE_CHECK([for ffi_prep_cif_var in ffi.h], [ac_cv_ffi_prep_cif_var], [ - AC_EGREP_HEADER([ffi_prep_cif_var], [ffi.h], [ac_cv_ffi_prep_cif_var=yes], [ac_cv_ffi_prep_cif_var=no]) - ]) - AS_VAR_IF([ac_cv_ffi_prep_cif_var], [yes], [ - AC_DEFINE([HAVE_FFI_PREP_CIF_VAR], [1], - [Define to 1 if you have the ffi_prep_cif_var function in header file.]) - ]) - - AC_CACHE_CHECK([for ffi_prep_closure_loc in ffi.h], [ac_cv_ffi_prep_closure_loc], [ - AC_EGREP_HEADER([ffi_prep_closure_loc], [ffi.h], [ac_cv_ffi_prep_closure_loc=yes], [ac_cv_ffi_prep_closure_loc=no]) - ]) - AS_VAR_IF([ac_cv_ffi_prep_closure_loc], [yes], [ - AC_DEFINE([HAVE_FFI_PREP_CLOSURE_LOC], [1], - [Define to 1 if you have the ffi_prep_closure_loc function in header file.]) - ]) - - AC_CACHE_CHECK([for ffi_closure_alloc in ffi.h], [ac_cv_ffi_closure_alloc], [ - AC_EGREP_HEADER([ffi_closure_alloc], [ffi.h], [ac_cv_ffi_closure_alloc=yes], [ac_cv_ffi_closure_alloc=no]) - ]) - AS_VAR_IF([ac_cv_ffi_closure_alloc], [yes], [ - AC_DEFINE([HAVE_FFI_CLOSURE_ALLOC], [1], - [Define to 1 if you have the ffi_closure_alloc function in header file.]) - ]) - ]) -fi - - if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" else @@ -6484,9 +6430,7 @@ PY_STDLIB_MOD([_blake2], [test "$with_builtin_blake2" = yes]) PY_STDLIB_MOD([_crypt], [], [test "$ac_cv_crypt_crypt" = yes], [$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS]) -PY_STDLIB_MOD([_ctypes], - [], [test "$have_libffi" = yes], - [$LIBFFI_CFLAGS], [$LIBFFI_LIBS]) +dnl PY_STDLIB_MOD([_ctypes], [], [], [], []) dnl PY_STDLIB_MOD([_curses], [], [], [], []) dnl PY_STDLIB_MOD([_curses_panel], [], [], [], []) PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS]) @@ -6530,9 +6474,7 @@ PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes]) PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes]) PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes]) PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes]) -PY_STDLIB_MOD([_ctypes_test], - [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes], - [], [$LIBM]) +PY_STDLIB_MOD([_ctypes_test], [test "$TEST_MODULES" = yes], [], [], [-lm]) dnl Limited API template modules. dnl The limited C API is not compatible with the Py_TRACE_REFS macro. diff --git a/pyconfig.h.in b/pyconfig.h.in index c6cc1fd3777626..efad243d0af8aa 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -356,18 +356,6 @@ /* Define to 1 if you have the `fexecve' function. */ #undef HAVE_FEXECVE -/* Define to 1 if you have the ffi_closure_alloc function in header - file. */ -#undef HAVE_FFI_CLOSURE_ALLOC - -/* Define to 1 if you have the ffi_prep_cif_var function in header - file. */ -#undef HAVE_FFI_PREP_CIF_VAR - -/* Define to 1 if you have the ffi_prep_closure_loc function in header - file. */ -#undef HAVE_FFI_PREP_CLOSURE_LOC - /* Define to 1 if you have the `flock' function. */ #undef HAVE_FLOCK diff --git a/setup.py b/setup.py index ca5d0774e001ac..572f2ac1783b88 100644 --- a/setup.py +++ b/setup.py @@ -669,6 +669,12 @@ def print_three_column(lst): raise RuntimeError("Failed to build some stdlib modules") def build_extension(self, ext): + + if ext.name == '_ctypes': + if not self.configure_ctypes(ext): + self.failed.append(ext.name) + return + try: build_ext.build_extension(self, ext) except (CCompilerError, DistutilsError) as why: @@ -1732,26 +1738,10 @@ def detect_tkinter(self): library_dirs=added_lib_dirs)) return True - def detect_ctypes(self): - ext = Extension( - '_ctypes', - [ - '_ctypes/_ctypes.c', - '_ctypes/callbacks.c', - '_ctypes/callproc.c', - '_ctypes/stgdict.c', - '_ctypes/cfield.c', - ] - ) - if MACOS: - self._build_ctypes_macos(ext) - else: - self.use_system_libffi = True - self.addext(ext) - - self.addext(Extension('_ctypes_test', ['_ctypes/_ctypes_test.c'])) + def configure_ctypes(self, ext): + return True - def _build_ctypes_macos(self, ext): + def detect_ctypes(self): # Thomas Heller's _ctypes module if (not sysconfig.get_config_var("LIBFFI_INCLUDEDIR") and MACOS): @@ -1759,11 +1749,20 @@ def _build_ctypes_macos(self, ext): else: self.use_system_libffi = '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS") + include_dirs = [] + extra_compile_args = [] + extra_link_args = [] + sources = ['_ctypes/_ctypes.c', + '_ctypes/callbacks.c', + '_ctypes/callproc.c', + '_ctypes/stgdict.c', + '_ctypes/cfield.c'] + if MACOS: - ext.sources.append('_ctypes/malloc_closure.c') - ext.extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1') - ext.extra_compile_args.append('-DMACOSX') - ext.include_dirs.append('_ctypes/darwin') + sources.append('_ctypes/malloc_closure.c') + extra_compile_args.append('-DUSING_MALLOC_CLOSURE_DOT_C=1') + extra_compile_args.append('-DMACOSX') + include_dirs.append('_ctypes/darwin') elif HOST_PLATFORM == 'sunos5': # XXX This shouldn't be necessary; it appears that some @@ -1774,12 +1773,20 @@ def _build_ctypes_macos(self, ext): # this option. If you want to compile ctypes with the Sun # compiler, please research a proper solution, instead of # finding some -z option for the Sun compiler. - ext.extra_link_args.append('-mimpure-text') + extra_link_args.append('-mimpure-text') elif HOST_PLATFORM.startswith('hp-ux'): - ext.extra_link_args.append('-fPIC') - + extra_link_args.append('-fPIC') + + ext = Extension('_ctypes', + include_dirs=include_dirs, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + libraries=[], + sources=sources) self.add(ext) + # function my_sqrt() needs libm for sqrt() + self.addext(Extension('_ctypes_test', ['_ctypes/_ctypes_test.c'])) ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR") ffi_lib = None