From 5596909eac4abdc9927c2e7751bea34fbcfdc624 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sat, 20 Nov 2021 11:18:48 +0200 Subject: [PATCH] bpo-45847: Port _scproxy to PY_STDLIB_MOD (GH-29644) --- Modules/Setup | 4 +-- Modules/Setup.stdlib.in | 7 +++++ configure | 60 +++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ setup.py | 7 ++--- 5 files changed, 74 insertions(+), 7 deletions(-) diff --git a/Modules/Setup b/Modules/Setup index 5a7c232d3c5..d3647ecb995 100644 --- a/Modules/Setup +++ b/Modules/Setup @@ -267,8 +267,8 @@ PYTHONPATH=$(COREPYTHONPATH) #_curses -lncurses -lncursesw -ltermcap _cursesmodule.c #_curses_panel -lpanel -lncurses _curses_panel.c -# macOS specific modules -# _scproxy _scproxy.c -framework SystemConfiguration -framework CoreFoundation +# macOS specific module, needs SystemConfiguration and CoreFoundation framework +# _scproxy _scproxy.c # Examples diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index ee07f4d5d8e..4e5c158c0fd 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -69,3 +69,10 @@ # Modules with third party dependencies # @MODULE__SQLITE3_TRUE@_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c + + +############################################################################ +# macOS specific modules + +# _scproxy needs SystemConfiguration and CoreFoundation framework +@MODULE__SCPROXY_TRUE@_scproxy _scproxy.c diff --git a/configure b/configure index e8935dfb625..9340cb07219 100755 --- a/configure +++ b/configure @@ -644,6 +644,8 @@ MODULE__ELEMENTTREE_FALSE MODULE__ELEMENTTREE_TRUE MODULE_PYEXPAT_FALSE MODULE_PYEXPAT_TRUE +MODULE__SCPROXY_FALSE +MODULE__SCPROXY_TRUE MODULE_OSSAUDIODEV_FALSE MODULE_OSSAUDIODEV_TRUE MODULE__DATETIME_FALSE @@ -19588,6 +19590,56 @@ fi $as_echo "$py_cv_module_ossaudiodev" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _scproxy" >&5 +$as_echo_n "checking for stdlib extension module _scproxy... " >&6; } + case $py_stdlib_not_available in #( + *_scproxy*) : + py_cv_module__scproxy=n/a ;; #( + *) : + + if test "$ac_sys_system" = "Darwin"; then : + if true; then : + py_cv_module__scproxy=yes +else + py_cv_module__scproxy=missing +fi +else + py_cv_module__scproxy=disabled + +fi + + ;; +esac + as_fn_append MODULE_BLOCK "MODULE__SCPROXY=$py_cv_module__scproxy$as_nl" + if test "x$py_cv_module__scproxy" = xyes; then : + + as_fn_append MODULE_BLOCK "MODULE__SCPROXY_CFLAGS=$as_nl" + as_fn_append MODULE_BLOCK "MODULE__SCPROXY_LDFLAGS=-framework SystemConfiguration -framework CoreFoundation$as_nl" + if true; then + MODULE__SCPROXY_TRUE= + MODULE__SCPROXY_FALSE='#' +else + MODULE__SCPROXY_TRUE='#' + MODULE__SCPROXY_FALSE= +fi + + +else + + if false; then + MODULE__SCPROXY_TRUE= + MODULE__SCPROXY_FALSE='#' +else + MODULE__SCPROXY_TRUE='#' + MODULE__SCPROXY_FALSE= +fi + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__scproxy" >&5 +$as_echo "$py_cv_module__scproxy" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module pyexpat" >&5 $as_echo_n "checking for stdlib extension module pyexpat... " >&6; } @@ -20231,6 +20283,14 @@ if test -z "${MODULE_OSSAUDIODEV_TRUE}" && test -z "${MODULE_OSSAUDIODEV_FALSE}" as_fn_error $? "conditional \"MODULE_OSSAUDIODEV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__SCPROXY_TRUE}" && test -z "${MODULE__SCPROXY_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SCPROXY\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__SCPROXY_TRUE}" && test -z "${MODULE__SCPROXY_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SCPROXY\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE_PYEXPAT_TRUE}" && test -z "${MODULE_PYEXPAT_FALSE}"; then as_fn_error $? "conditional \"MODULE_PYEXPAT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 754b066f52e..924659713e4 100644 --- a/configure.ac +++ b/configure.ac @@ -6062,6 +6062,9 @@ PY_STDLIB_MOD_SIMPLE([_datetime], [], [$TIMEMODULE_LIB $LIBM]) dnl platform specific extensions PY_STDLIB_MOD([ossaudiodev], [], [test "$ac_cv_header_linux_soundcard_h" = yes -o "$ac_cv_header_sys_soundcard_h" = yes]) +PY_STDLIB_MOD([_scproxy], + [test "$ac_sys_system" = "Darwin"], [], + [], [-framework SystemConfiguration -framework CoreFoundation]) dnl _elementtree loads libexpat via CAPI hook in pyexpat PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS]) diff --git a/setup.py b/setup.py index 3e3075d8d9a..83a676bfefb 100644 --- a/setup.py +++ b/setup.py @@ -1389,11 +1389,8 @@ def detect_platform_specific_exts(self): # linux/soundcard.h or sys/soundcard.h self.addext(Extension('ossaudiodev', ['ossaudiodev.c'])) - if MACOS: - self.add(Extension('_scproxy', ['_scproxy.c'], - extra_link_args=[ - '-framework', 'SystemConfiguration', - '-framework', 'CoreFoundation'])) + # macOS-only, needs SystemConfiguration and CoreFoundation framework + self.addext(Extension('_scproxy', ['_scproxy.c'])) def detect_compress_exts(self): # Andrew Kuchling's zlib module.