From 133c65a870e8bdcce7cd6a2bc6bd0cefbb2fa9f3 Mon Sep 17 00:00:00 2001 From: Erlend Egeberg Aasland Date: Mon, 22 Nov 2021 09:05:36 +0100 Subject: [PATCH] bpo-45847: Port array, _contextvars, math, and cmath to PY_STDLIB_MOD_SIMPLE (GH-29688) --- Modules/Setup.stdlib.in | 6 ++++ configure | 76 +++++++++++++++++++++++++++++++++++++++++ configure.ac | 4 +++ setup.py | 10 +++--- 4 files changed, 90 insertions(+), 6 deletions(-) diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 42755c952f9..b22a956f0c4 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -28,6 +28,12 @@ ############################################################################ # Modules that should always be present (POSIX and Windows): +@MODULE_ARRAY_TRUE@array arraymodule.c +@MODULE__CONTEXTVARS_TRUE@_contextvars _contextvarsmodule.c + +# needs libm +@MODULE_MATH_TRUE@math mathmodule.c +@MODULE_CMATH_TRUE@cmath cmathmodule.c # needs libm and on some platforms librt @MODULE__DATETIME_TRUE@_datetime _datetimemodule.c diff --git a/configure b/configure index fd75c52ab3d..72285a6eeae 100755 --- a/configure +++ b/configure @@ -688,8 +688,16 @@ MODULE_OSSAUDIODEV_FALSE MODULE_OSSAUDIODEV_TRUE MODULE_GRP_FALSE MODULE_GRP_TRUE +MODULE_CMATH_FALSE +MODULE_CMATH_TRUE +MODULE_MATH_FALSE +MODULE_MATH_TRUE MODULE__DATETIME_FALSE MODULE__DATETIME_TRUE +MODULE__CONTEXTVARS_FALSE +MODULE__CONTEXTVARS_TRUE +MODULE_ARRAY_FALSE +MODULE_ARRAY_TRUE MODULE_TIME_FALSE MODULE_TIME_TRUE MODULE__IO_FALSE @@ -19566,6 +19574,30 @@ fi + if true; then + MODULE_ARRAY_TRUE= + MODULE_ARRAY_FALSE='#' +else + MODULE_ARRAY_TRUE='#' + MODULE_ARRAY_FALSE= +fi + + + + + + if true; then + MODULE__CONTEXTVARS_TRUE= + MODULE__CONTEXTVARS_FALSE='#' +else + MODULE__CONTEXTVARS_TRUE='#' + MODULE__CONTEXTVARS_FALSE= +fi + + + + + if true; then MODULE__DATETIME_TRUE= MODULE__DATETIME_FALSE='#' @@ -19580,6 +19612,34 @@ fi + if true; then + MODULE_MATH_TRUE= + MODULE_MATH_FALSE='#' +else + MODULE_MATH_TRUE='#' + MODULE_MATH_FALSE= +fi + + + + as_fn_append MODULE_BLOCK "MODULE_MATH_LDFLAGS=$LIBM$as_nl" + + + + if true; then + MODULE_CMATH_TRUE= + MODULE_CMATH_FALSE='#' +else + MODULE_CMATH_TRUE='#' + MODULE_CMATH_FALSE= +fi + + + + as_fn_append MODULE_BLOCK "MODULE_CMATH_LDFLAGS=$LIBM$as_nl" + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5 $as_echo_n "checking for stdlib extension module grp... " >&6; } @@ -20745,10 +20805,26 @@ if test -z "${MODULE_TIME_TRUE}" && test -z "${MODULE_TIME_FALSE}"; then as_fn_error $? "conditional \"MODULE_TIME\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE_ARRAY_TRUE}" && test -z "${MODULE_ARRAY_FALSE}"; then + as_fn_error $? "conditional \"MODULE_ARRAY\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CONTEXTVARS_TRUE}" && test -z "${MODULE__CONTEXTVARS_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CONTEXTVARS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE__DATETIME_TRUE}" && test -z "${MODULE__DATETIME_FALSE}"; then as_fn_error $? "conditional \"MODULE__DATETIME\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE_MATH_TRUE}" && test -z "${MODULE_MATH_FALSE}"; then + as_fn_error $? "conditional \"MODULE_MATH\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE_CMATH_TRUE}" && test -z "${MODULE_CMATH_FALSE}"; then + as_fn_error $? "conditional \"MODULE_CMATH\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE_GRP_TRUE}" && test -z "${MODULE_GRP_FALSE}"; then as_fn_error $? "conditional \"MODULE_GRP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 63df5188d38..e0013c71ac8 100644 --- a/configure.ac +++ b/configure.ac @@ -6075,7 +6075,11 @@ PY_STDLIB_MOD_SIMPLE([_io], [-I\$(srcdir)/Modules/_io], []) PY_STDLIB_MOD_SIMPLE([time], [], [$TIMEMODULE_LIB]) dnl always enabled extension modules +PY_STDLIB_MOD_SIMPLE([array]) +PY_STDLIB_MOD_SIMPLE([_contextvars]) PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM]) +PY_STDLIB_MOD_SIMPLE([math], [], [$LIBM]) +PY_STDLIB_MOD_SIMPLE([cmath], [], [$LIBM]) dnl platform specific extensions PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes]) diff --git a/setup.py b/setup.py index 13ed636b13f..b2a3f4eb714 100644 --- a/setup.py +++ b/setup.py @@ -984,18 +984,16 @@ class PyBuildExt(build_ext): # # array objects - self.add(Extension('array', ['arraymodule.c'])) + self.addext(Extension('array', ['arraymodule.c'])) # Context Variables - self.add(Extension('_contextvars', ['_contextvarsmodule.c'])) + self.addext(Extension('_contextvars', ['_contextvarsmodule.c'])) # math library functions, e.g. sin() - self.add(Extension('math', ['mathmodule.c'], - libraries=['m'])) + self.addext(Extension('math', ['mathmodule.c'])) # complex math library functions - self.add(Extension('cmath', ['cmathmodule.c'], - libraries=['m'])) + self.addext(Extension('cmath', ['cmathmodule.c'])) # time libraries: librt may be needed for clock_gettime() time_libs = []