From ab0dd55570c36b1e6a9d32f87256a21714cc75d6 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 21 Nov 2021 11:19:20 +0100 Subject: [PATCH] bpo-45847: Port codecs and unicodedata to PY_STDLIB_MOD Signed-off-by: Christian Heimes --- Modules/Setup.stdlib.in | 8 +++ configure | 144 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 8 +++ setup.py | 11 +-- 4 files changed, 166 insertions(+), 5 deletions(-) diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 495cfb47ac2315..42755c952f9720 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -56,6 +56,14 @@ # _elementtree libexpat via CAPI hook in pyexpat. @MODULE__ELEMENTTREE_TRUE@_elementtree _elementtree.c +@MODULE__CODECS_CN_TRUE@_codecs_cn cjkcodecs/_codecs_cn.c +@MODULE__CODECS_HK_TRUE@_codecs_hk cjkcodecs/_codecs_hk.c +@MODULE__CODECS_ISO2022_TRUE@_codecs_iso2022 cjkcodecs/_codecs_iso2022.c +@MODULE__CODECS_JP_TRUE@_codecs_jp cjkcodecs/_codecs_jp.c +@MODULE__CODECS_KR_TRUE@_codecs_kr cjkcodecs/_codecs_kr.c +@MODULE__CODECS_TW_TRUE@_codecs_tw cjkcodecs/_codecs_tw.c +@MODULE__MULTIBYTECODEC_TRUE@_multibytecodec cjkcodecs/multibytecodec.c +@MODULE_UNICODEDATA_TRUE@unicodedata unicodedata.c ############################################################################ # Modules with some UNIX dependencies diff --git a/configure b/configure index 45c6eb4b845ab7..7bf2cfb257f5f5 100755 --- a/configure +++ b/configure @@ -654,6 +654,22 @@ MODULE__SHA1_FALSE MODULE__SHA1_TRUE MODULE__MD5_FALSE MODULE__MD5_TRUE +MODULE_UNICODEDATA_FALSE +MODULE_UNICODEDATA_TRUE +MODULE__MULTIBYTECODEC_FALSE +MODULE__MULTIBYTECODEC_TRUE +MODULE__CODECS_TW_FALSE +MODULE__CODECS_TW_TRUE +MODULE__CODECS_KR_FALSE +MODULE__CODECS_KR_TRUE +MODULE__CODECS_JP_FALSE +MODULE__CODECS_JP_TRUE +MODULE__CODECS_ISO2022_FALSE +MODULE__CODECS_ISO2022_TRUE +MODULE__CODECS_HK_FALSE +MODULE__CODECS_HK_TRUE +MODULE__CODECS_CN_FALSE +MODULE__CODECS_CN_TRUE MODULE__ELEMENTTREE_FALSE MODULE__ELEMENTTREE_TRUE MODULE_PYEXPAT_FALSE @@ -19913,6 +19929,102 @@ fi $as_echo "$py_cv_module__elementtree" >&6; } + if true; then + MODULE__CODECS_CN_TRUE= + MODULE__CODECS_CN_FALSE='#' +else + MODULE__CODECS_CN_TRUE='#' + MODULE__CODECS_CN_FALSE= +fi + + + + + + if true; then + MODULE__CODECS_HK_TRUE= + MODULE__CODECS_HK_FALSE='#' +else + MODULE__CODECS_HK_TRUE='#' + MODULE__CODECS_HK_FALSE= +fi + + + + + + if true; then + MODULE__CODECS_ISO2022_TRUE= + MODULE__CODECS_ISO2022_FALSE='#' +else + MODULE__CODECS_ISO2022_TRUE='#' + MODULE__CODECS_ISO2022_FALSE= +fi + + + + + + if true; then + MODULE__CODECS_JP_TRUE= + MODULE__CODECS_JP_FALSE='#' +else + MODULE__CODECS_JP_TRUE='#' + MODULE__CODECS_JP_FALSE= +fi + + + + + + if true; then + MODULE__CODECS_KR_TRUE= + MODULE__CODECS_KR_FALSE='#' +else + MODULE__CODECS_KR_TRUE='#' + MODULE__CODECS_KR_FALSE= +fi + + + + + + if true; then + MODULE__CODECS_TW_TRUE= + MODULE__CODECS_TW_FALSE='#' +else + MODULE__CODECS_TW_TRUE='#' + MODULE__CODECS_TW_FALSE= +fi + + + + + + if true; then + MODULE__MULTIBYTECODEC_TRUE= + MODULE__MULTIBYTECODEC_FALSE='#' +else + MODULE__MULTIBYTECODEC_TRUE='#' + MODULE__MULTIBYTECODEC_FALSE= +fi + + + + + + if true; then + MODULE_UNICODEDATA_TRUE= + MODULE_UNICODEDATA_FALSE='#' +else + MODULE_UNICODEDATA_TRUE='#' + MODULE_UNICODEDATA_FALSE= +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _md5" >&5 $as_echo_n "checking for stdlib extension module _md5... " >&6; } @@ -20669,6 +20781,38 @@ if test -z "${MODULE__ELEMENTTREE_TRUE}" && test -z "${MODULE__ELEMENTTREE_FALSE as_fn_error $? "conditional \"MODULE__ELEMENTTREE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__CODECS_CN_TRUE}" && test -z "${MODULE__CODECS_CN_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_CN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CODECS_HK_TRUE}" && test -z "${MODULE__CODECS_HK_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_HK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CODECS_ISO2022_TRUE}" && test -z "${MODULE__CODECS_ISO2022_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_ISO2022\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CODECS_JP_TRUE}" && test -z "${MODULE__CODECS_JP_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_JP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CODECS_KR_TRUE}" && test -z "${MODULE__CODECS_KR_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_KR\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__CODECS_TW_TRUE}" && test -z "${MODULE__CODECS_TW_FALSE}"; then + as_fn_error $? "conditional \"MODULE__CODECS_TW\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__MULTIBYTECODEC_TRUE}" && test -z "${MODULE__MULTIBYTECODEC_FALSE}"; then + as_fn_error $? "conditional \"MODULE__MULTIBYTECODEC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE_UNICODEDATA_TRUE}" && test -z "${MODULE_UNICODEDATA_FALSE}"; then + as_fn_error $? "conditional \"MODULE_UNICODEDATA\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE__MD5_TRUE}" && test -z "${MODULE__MD5_FALSE}"; then as_fn_error $? "conditional \"MODULE__MD5\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 3d6233f31d9cb2..e263993640e4c0 100644 --- a/configure.ac +++ b/configure.ac @@ -6074,6 +6074,14 @@ PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes]) dnl _elementtree loads libexpat via CAPI hook in pyexpat PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS]) PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], []) +PY_STDLIB_MOD_SIMPLE([_codecs_cn]) +PY_STDLIB_MOD_SIMPLE([_codecs_hk]) +PY_STDLIB_MOD_SIMPLE([_codecs_iso2022]) +PY_STDLIB_MOD_SIMPLE([_codecs_jp]) +PY_STDLIB_MOD_SIMPLE([_codecs_kr]) +PY_STDLIB_MOD_SIMPLE([_codecs_tw]) +PY_STDLIB_MOD_SIMPLE([_multibytecodec]) +PY_STDLIB_MOD_SIMPLE([unicodedata]) dnl By default we always compile these even when OpenSSL is available dnl (issue #14693). The modules are small. diff --git a/setup.py b/setup.py index 9ff5969c296135..13ed636b13f0c0 100644 --- a/setup.py +++ b/setup.py @@ -1022,7 +1022,7 @@ def detect_simple_extensions(self): # profiler (_lsprof is for cProfile.py) self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'])) # static Unicode character database - self.add(Extension('unicodedata', ['unicodedata.c'])) + self.addext(Extension('unicodedata', ['unicodedata.c'])) # _opcode module self.add(Extension('_opcode', ['_opcode.c'])) # asyncio speedups @@ -1432,11 +1432,12 @@ def detect_expat_elementtree(self): def detect_multibytecodecs(self): # Hye-Shik Chang's CJKCodecs modules. - self.add(Extension('_multibytecodec', - ['cjkcodecs/multibytecodec.c'])) + self.addext(Extension('_multibytecodec', + ['cjkcodecs/multibytecodec.c'])) for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): - self.add(Extension('_codecs_%s' % loc, - ['cjkcodecs/_codecs_%s.c' % loc])) + self.addext(Extension( + f'_codecs_{loc}', [f'cjkcodecs/_codecs_{loc}.c'] + )) def detect_multiprocessing(self): # Richard Oudkerk's multiprocessing module