From d5397d30d44615916f481a04490be6749a098115 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 22 Nov 2021 11:48:13 +0100 Subject: [PATCH 1/3] bpo-45847: Port socket to PY_STDLIB_MOD_SIMPLE --- Modules/Setup.stdlib.in | 1 + configure | 44 ++++++++++++++++++++++++++++++++++++++++- configure.ac | 6 +++++- pyconfig.h.in | 3 +++ setup.py | 6 ++---- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index b12ae9db5e9b25..35ced4c4c0de4a 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -109,6 +109,7 @@ @MODULE__POSIXSUBPROCESS_TRUE@_posixsubprocess _posixsubprocess.c @MODULE_RESOURCE_TRUE@resource resource.c @MODULE_SELECT_TRUE@select selectmodule.c +@MODULE__SOCKET_TRUE@_socket socketmodule.c # AIX has shadow passwords, but does not provide getspent API @MODULE_SPWD_TRUE@spwd spwdmodule.c @MODULE_SYSLOG_TRUE@syslog syslogmodule.c diff --git a/configure b/configure index a1fc09fc048545..c542d08a291a13 100755 --- a/configure +++ b/configure @@ -698,6 +698,8 @@ MODULE_OSSAUDIODEV_FALSE MODULE_OSSAUDIODEV_TRUE MODULE_GRP_FALSE MODULE_GRP_TRUE +MODULE__SOCKET_FALSE +MODULE__SOCKET_TRUE MODULE_MMAP_FALSE MODULE_MMAP_TRUE MODULE_FCNTL_FALSE @@ -8309,7 +8311,7 @@ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \ -sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h +sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h netinet/in.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -20739,6 +20741,42 @@ fi $as_echo "$py_cv_module_mmap" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _socket" >&5 +$as_echo_n "checking for stdlib extension module _socket... " >&6; } + case $py_stdlib_not_available in #( + *_socket*) : + py_cv_module__socket=n/a ;; #( + *) : + if true; then : + if test "$ac_cv_header_sys_socket_h" = "yes" -a "$ac_cv_header_sys_types_h" = "yes" -a "$ac_cv_header_netinet_in_h" = "yes"; then : + py_cv_module__socket=yes +else + py_cv_module__socket=missing +fi +else + py_cv_module__socket=disabled +fi + ;; +esac + as_fn_append MODULE_BLOCK "MODULE__SOCKET=$py_cv_module__socket$as_nl" + if test "x$py_cv_module__socket" = xyes; then : + + + + +fi + if test "$py_cv_module__socket" = yes; then + MODULE__SOCKET_TRUE= + MODULE__SOCKET_FALSE='#' +else + MODULE__SOCKET_TRUE='#' + MODULE__SOCKET_FALSE= +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__socket" >&5 +$as_echo "$py_cv_module__socket" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5 $as_echo_n "checking for stdlib extension module grp... " >&6; } @@ -22066,6 +22104,10 @@ if test -z "${MODULE_MMAP_TRUE}" && test -z "${MODULE_MMAP_FALSE}"; then as_fn_error $? "conditional \"MODULE_MMAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__SOCKET_TRUE}" && test -z "${MODULE__SOCKET_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SOCKET\" 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 5757c3b2586bc3..7e169bcb9ba327 100644 --- a/configure.ac +++ b/configure.ac @@ -2188,7 +2188,7 @@ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \ -sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h) +sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h netinet/in.h) AC_HEADER_DIRENT AC_HEADER_MAJOR @@ -6157,6 +6157,10 @@ PY_STDLIB_MOD([fcntl], [], [$FCNTL_LIBS]) PY_STDLIB_MOD([mmap], [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"]) +PY_STDLIB_MOD([_socket], + [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes" + -a "$ac_cv_header_sys_types_h" = "yes" + -a "$ac_cv_header_netinet_in_h" = "yes"])) dnl platform specific extensions PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes]) diff --git a/pyconfig.h.in b/pyconfig.h.in index c9c58656f58ac4..6b2aa803eadf41 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -757,6 +757,9 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + /* Define to 1 if you have the header file. */ #undef HAVE_NETPACKET_PACKET_H diff --git a/setup.py b/setup.py index a3aa787a1b7082..eed92ec0565e07 100644 --- a/setup.py +++ b/setup.py @@ -1034,6 +1034,8 @@ def detect_simple_extensions(self): self.addext(Extension('fcntl', ['fcntlmodule.c'])) # grp(3) self.addext(Extension('grp', ['grpmodule.c'])) + + self.addext(Extension('_socket', ['socketmodule.c'])) self.addext(Extension('spwd', ['spwdmodule.c'])) # select(2); not on ancient System V @@ -1254,9 +1256,6 @@ def detect_crypt(self): self.add(Extension('_crypt', ['_cryptmodule.c'], libraries=libs)) - def detect_socket(self): - self.add(Extension('_socket', ['socketmodule.c'])) - def detect_dbm_gdbm(self): # Modules that provide persistent dictionary-like semantics. You will # probably want to arrange for at least one of them to be available on @@ -1460,7 +1459,6 @@ def detect_modules(self): self.detect_test_extensions() self.detect_readline_curses() self.detect_crypt() - self.detect_socket() self.detect_openssl_hashlib() self.detect_hash_builtins() self.detect_dbm_gdbm() From e45604c400cef415d4d947d7f6bc1aab0e1f7a8e Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 22 Nov 2021 21:47:58 +0100 Subject: [PATCH 2/3] Address review: remove checks --- configure | 57 ++++++++++++++-------------------------------------- configure.ac | 5 +---- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/configure b/configure index c542d08a291a13..ca8681ca5d49b9 100755 --- a/configure +++ b/configure @@ -698,8 +698,6 @@ MODULE_OSSAUDIODEV_FALSE MODULE_OSSAUDIODEV_TRUE MODULE_GRP_FALSE MODULE_GRP_TRUE -MODULE__SOCKET_FALSE -MODULE__SOCKET_TRUE MODULE_MMAP_FALSE MODULE_MMAP_TRUE MODULE_FCNTL_FALSE @@ -722,6 +720,8 @@ MODULE__TYPING_FALSE MODULE__TYPING_TRUE MODULE__STRUCT_FALSE MODULE__STRUCT_TRUE +MODULE__SOCKET_FALSE +MODULE__SOCKET_TRUE MODULE_SELECT_FALSE MODULE_SELECT_TRUE MODULE__RANDOM_FALSE @@ -20575,6 +20575,15 @@ else fi as_fn_append MODULE_BLOCK "MODULE_SELECT=yes$as_nl" + if true; then + MODULE__SOCKET_TRUE= + MODULE__SOCKET_FALSE='#' +else + MODULE__SOCKET_TRUE='#' + MODULE__SOCKET_FALSE= +fi + as_fn_append MODULE_BLOCK "MODULE__SOCKET=yes$as_nl" + if true; then MODULE__STRUCT_TRUE= MODULE__STRUCT_FALSE='#' @@ -20741,42 +20750,6 @@ fi $as_echo "$py_cv_module_mmap" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _socket" >&5 -$as_echo_n "checking for stdlib extension module _socket... " >&6; } - case $py_stdlib_not_available in #( - *_socket*) : - py_cv_module__socket=n/a ;; #( - *) : - if true; then : - if test "$ac_cv_header_sys_socket_h" = "yes" -a "$ac_cv_header_sys_types_h" = "yes" -a "$ac_cv_header_netinet_in_h" = "yes"; then : - py_cv_module__socket=yes -else - py_cv_module__socket=missing -fi -else - py_cv_module__socket=disabled -fi - ;; -esac - as_fn_append MODULE_BLOCK "MODULE__SOCKET=$py_cv_module__socket$as_nl" - if test "x$py_cv_module__socket" = xyes; then : - - - - -fi - if test "$py_cv_module__socket" = yes; then - MODULE__SOCKET_TRUE= - MODULE__SOCKET_FALSE='#' -else - MODULE__SOCKET_TRUE='#' - MODULE__SOCKET_FALSE= -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__socket" >&5 -$as_echo "$py_cv_module__socket" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module grp" >&5 $as_echo_n "checking for stdlib extension module grp... " >&6; } @@ -22060,6 +22033,10 @@ if test -z "${MODULE_SELECT_TRUE}" && test -z "${MODULE_SELECT_FALSE}"; then as_fn_error $? "conditional \"MODULE_SELECT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__SOCKET_TRUE}" && test -z "${MODULE__SOCKET_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SOCKET\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE__STRUCT_TRUE}" && test -z "${MODULE__STRUCT_FALSE}"; then as_fn_error $? "conditional \"MODULE__STRUCT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -22104,10 +22081,6 @@ if test -z "${MODULE_MMAP_TRUE}" && test -z "${MODULE_MMAP_FALSE}"; then as_fn_error $? "conditional \"MODULE_MMAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${MODULE__SOCKET_TRUE}" && test -z "${MODULE__SOCKET_FALSE}"; then - as_fn_error $? "conditional \"MODULE__SOCKET\" 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 7e169bcb9ba327..9e8a115f0b9f1d 100644 --- a/configure.ac +++ b/configure.ac @@ -6137,6 +6137,7 @@ PY_STDLIB_MOD_SIMPLE([_posixsubprocess]) PY_STDLIB_MOD_SIMPLE([_queue]) PY_STDLIB_MOD_SIMPLE([_random]) PY_STDLIB_MOD_SIMPLE([select]) +PY_STDLIB_MOD_SIMPLE([_socket]) PY_STDLIB_MOD_SIMPLE([_struct]) PY_STDLIB_MOD_SIMPLE([_typing]) PY_STDLIB_MOD_SIMPLE([_xxsubinterpreters]) @@ -6157,10 +6158,6 @@ PY_STDLIB_MOD([fcntl], [], [$FCNTL_LIBS]) PY_STDLIB_MOD([mmap], [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"]) -PY_STDLIB_MOD([_socket], - [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes" - -a "$ac_cv_header_sys_types_h" = "yes" - -a "$ac_cv_header_netinet_in_h" = "yes"])) dnl platform specific extensions PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes]) From 7d506ca1eee9adc76b8b70324fa624e6bfa203f0 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 22 Nov 2021 21:49:44 +0100 Subject: [PATCH 3/3] Also remove netinet/in.h check --- configure | 2 +- configure.ac | 2 +- pyconfig.h.in | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configure b/configure index ca8681ca5d49b9..342f47cc0ac1ba 100755 --- a/configure +++ b/configure @@ -8311,7 +8311,7 @@ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \ -sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h netinet/in.h +sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/configure.ac b/configure.ac index 9e8a115f0b9f1d..6fb1b662f08479 100644 --- a/configure.ac +++ b/configure.ac @@ -2188,7 +2188,7 @@ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ sys/endian.h sys/sysmacros.h linux/memfd.h linux/wait.h sys/memfd.h \ -sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h netinet/in.h) +sys/mman.h sys/eventfd.h linux/soundcard.h sys/soundcard.h syslog.h) AC_HEADER_DIRENT AC_HEADER_MAJOR diff --git a/pyconfig.h.in b/pyconfig.h.in index 6b2aa803eadf41..c9c58656f58ac4 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -757,9 +757,6 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - /* Define to 1 if you have the header file. */ #undef HAVE_NETPACKET_PACKET_H