From fc36305c25e11041a5a1f47a2963c238e14624be Mon Sep 17 00:00:00 2001 From: ggqlq Date: Wed, 7 May 2025 22:18:07 +0800 Subject: [PATCH 1/7] gh-131178: Add tests for command-line interface --- Lib/test/test_site.py | 94 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index a7e9241f44d243..10dcef4ec04664 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -15,6 +15,7 @@ from test.support.os_helper import TESTFN, EnvironmentVarGuard import ast import builtins +import fnmatch import glob import io import os @@ -25,6 +26,7 @@ import sys import sysconfig import tempfile +from textwrap import dedent import urllib.error import urllib.request from unittest import mock @@ -805,5 +807,97 @@ def test_underpth_dll_file(self): self.assertTrue(rc, "sys.path is incorrect") +class CommandLineTests(unittest.TestCase): + def setUp(self): + super().setUp() + if sys.path[0] != os.getcwd(): + sys.path.remove(sys.path[0]) + sys.path.insert(0, os.getcwd()) + + def get_excepted_output(self, *args): + if len(args) == 0: + user_base = site.getuserbase() + user_site = site.getusersitepackages() + output = "sys.path = [\n" + for dir in sys.path: + output += " %r,\n" % (dir,) + output += "]\n" + def exists(path): + if path is not None and os.path.isdir(path): + return "exists" + else: + return "doesn't exist" + output += f"USER_BASE: {user_base!r} ({exists(user_base)})\n" + output += f"USER_SITE: {user_site!r} ({exists(user_site)})\n" + output += f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE!r}\n" + return 0, dedent(output).strip() + + buffer = [] + if '--user-base' in args: + buffer.append(site.getuserbase()) + if '--user-site' in args: + buffer.append(site.getusersitepackages()) + + if buffer: + return_code = 3 + if site.ENABLE_USER_SITE: + return_code = 0 + elif site.ENABLE_USER_SITE is False: + return_code = 1 + elif site.ENABLE_USER_SITE is None: + return_code = 2 + output = os.pathsep.join(buffer) + return return_code, dedent(output).strip() + else: + return 10, None + + def invoke_command_line(self, *args): + args = [sys.executable, "-m", "site", *args] + proc = subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT,) + proc.wait() + output = proc.stdout.read().decode() + return_code = proc.returncode + proc.stdout.close() + return return_code, dedent(output).strip() + + def test_no_args(self): + return_code, output = self.invoke_command_line() + excepted_return_code, excepted_output = self.get_excepted_output() + self.assertEqual(return_code, excepted_return_code) + self.assertEqual(output, excepted_output) + # self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + + def test_unknown_args(self): + return_code, output = self.invoke_command_line("--unknown-arg") + excepted_return_code, _ = self.get_excepted_output("--unknown-arg") + self.assertEqual(return_code, excepted_return_code) + self.assertIn('[--user-base] [--user-site]', output) + + def test_base_arg(self): + return_code, output = self.invoke_command_line("--user-base") + excepted = self.get_excepted_output("--user-base") + excepted_return_code, excepted_output = excepted + self.assertEqual(return_code, excepted_return_code) + self.assertEqual(output, excepted_output) + self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + + def test_site_arg(self): + return_code, output = self.invoke_command_line("--user-site") + excepted = self.get_excepted_output("--user-site") + excepted_return_code, excepted_output = excepted + self.assertEqual(return_code, excepted_return_code) + self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + + def test_both_args(self): + return_code, output = self.invoke_command_line("--user-base", + "--user-site") + excepted = self.get_excepted_output("--user-base", "--user-site") + excepted_return_code, excepted_output = excepted + self.assertEqual(return_code, excepted_return_code) + self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + + if __name__ == "__main__": unittest.main() From 6497282c6084fa66760d5831e738f1509005c35f Mon Sep 17 00:00:00 2001 From: ggqlq Date: Wed, 7 May 2025 22:31:52 +0800 Subject: [PATCH 2/7] gh-131178: Add tests for site command-line interface --- Lib/test/test_site.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 10dcef4ec04664..61f64121c49a83 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -867,7 +867,6 @@ def test_no_args(self): excepted_return_code, excepted_output = self.get_excepted_output() self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) - # self.assertTrue(fnmatch.fnmatch(output, excepted_output)) def test_unknown_args(self): return_code, output = self.invoke_command_line("--unknown-arg") @@ -881,14 +880,13 @@ def test_base_arg(self): excepted_return_code, excepted_output = excepted self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) - self.assertTrue(fnmatch.fnmatch(output, excepted_output)) def test_site_arg(self): return_code, output = self.invoke_command_line("--user-site") excepted = self.get_excepted_output("--user-site") excepted_return_code, excepted_output = excepted self.assertEqual(return_code, excepted_return_code) - self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + self.assertEqual(output, excepted_output) def test_both_args(self): return_code, output = self.invoke_command_line("--user-base", @@ -896,7 +894,7 @@ def test_both_args(self): excepted = self.get_excepted_output("--user-base", "--user-site") excepted_return_code, excepted_output = excepted self.assertEqual(return_code, excepted_return_code) - self.assertTrue(fnmatch.fnmatch(output, excepted_output)) + self.assertEqual(output, excepted_output) if __name__ == "__main__": From b1ec14dd745245b2f474dd06c2b0872551437f08 Mon Sep 17 00:00:00 2001 From: ggqlq Date: Wed, 7 May 2025 22:32:14 +0800 Subject: [PATCH 3/7] gh-131178: Add tests for site command-line interface --- Lib/test/test_site.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 61f64121c49a83..1fafa2b7b64f1c 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -15,7 +15,6 @@ from test.support.os_helper import TESTFN, EnvironmentVarGuard import ast import builtins -import fnmatch import glob import io import os From 6e8d75e44f56d76fd6d89e9922c2585011161461 Mon Sep 17 00:00:00 2001 From: ggqlq Date: Thu, 8 May 2025 11:33:57 +0800 Subject: [PATCH 4/7] fix --- Lib/test/test_site.py | 46 +++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 1fafa2b7b64f1c..12e44c4134d110 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -807,11 +807,11 @@ def test_underpth_dll_file(self): class CommandLineTests(unittest.TestCase): - def setUp(self): - super().setUp() - if sys.path[0] != os.getcwd(): - sys.path.remove(sys.path[0]) - sys.path.insert(0, os.getcwd()) + def exists(self, path): + if path is not None and os.path.isdir(path): + return "exists" + else: + return "doesn't exist" def get_excepted_output(self, *args): if len(args) == 0: @@ -821,13 +821,8 @@ def get_excepted_output(self, *args): for dir in sys.path: output += " %r,\n" % (dir,) output += "]\n" - def exists(path): - if path is not None and os.path.isdir(path): - return "exists" - else: - return "doesn't exist" - output += f"USER_BASE: {user_base!r} ({exists(user_base)})\n" - output += f"USER_SITE: {user_site!r} ({exists(user_site)})\n" + output += f"USER_BASE: {user_base!r} ({self.exists(user_base)})\n" + output += f"USER_SITE: {user_site!r} ({self.exists(user_site)})\n" output += f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE!r}\n" return 0, dedent(output).strip() @@ -854,25 +849,40 @@ def invoke_command_line(self, *args): args = [sys.executable, "-m", "site", *args] proc = subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT,) + stderr=subprocess.STDOUT, + text=True) proc.wait() - output = proc.stdout.read().decode() + output = proc.stdout.read() return_code = proc.returncode proc.stdout.close() return return_code, dedent(output).strip() + @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_no_args(self): return_code, output = self.invoke_command_line() - excepted_return_code, excepted_output = self.get_excepted_output() + excepted_return_code, _ = self.get_excepted_output() self.assertEqual(return_code, excepted_return_code) - self.assertEqual(output, excepted_output) - + lines = output.splitlines() + self.assertEqual(lines[0], "sys.path = [") + self.assertEqual(lines[-4], "]") + excepted_base = f"USER_BASE: '{site.getuserbase()}'" +\ + f" ({self.exists(site.getuserbase())})" + print(excepted_base) + self.assertEqual(lines[-3], excepted_base) + excepted_site = f"USER_SITE: '{site.getusersitepackages()}'" +\ + f" ({self.exists(site.getusersitepackages())})" + self.assertEqual(lines[-2], excepted_site) + self.assertEqual(lines[-1], f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}") + + + @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_unknown_args(self): return_code, output = self.invoke_command_line("--unknown-arg") excepted_return_code, _ = self.get_excepted_output("--unknown-arg") self.assertEqual(return_code, excepted_return_code) self.assertIn('[--user-base] [--user-site]', output) + @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_base_arg(self): return_code, output = self.invoke_command_line("--user-base") excepted = self.get_excepted_output("--user-base") @@ -880,6 +890,7 @@ def test_base_arg(self): self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) + @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_site_arg(self): return_code, output = self.invoke_command_line("--user-site") excepted = self.get_excepted_output("--user-site") @@ -887,6 +898,7 @@ def test_site_arg(self): self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) + @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_both_args(self): return_code, output = self.invoke_command_line("--user-base", "--user-site") From 3c1ba46cca6a3b840a856a76e93bcd7a27bd11d3 Mon Sep 17 00:00:00 2001 From: ggqlq Date: Thu, 8 May 2025 13:44:33 +0800 Subject: [PATCH 5/7] fix windows --- Lib/test/test_site.py | 15 ++- confdefs.h | 216 ++++++++++++++++++++++++++++++++++++ conftest.c | 248 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 474 insertions(+), 5 deletions(-) create mode 100644 confdefs.h create mode 100644 conftest.c diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 12e44c4134d110..39b2f0d5291901 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -841,21 +841,28 @@ def get_excepted_output(self, *args): elif site.ENABLE_USER_SITE is None: return_code = 2 output = os.pathsep.join(buffer) - return return_code, dedent(output).strip() + return return_code, os.path.normpath(dedent(output).strip()) else: return 10, None def invoke_command_line(self, *args): args = [sys.executable, "-m", "site", *args] + env = os.environ.copy() + env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf-8" + proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - text=True) + text=True, + env=env, + encoding='utf-8', + errors='replace') proc.wait() output = proc.stdout.read() return_code = proc.returncode proc.stdout.close() - return return_code, dedent(output).strip() + return return_code, os.path.normpath(dedent(output).strip()) @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_no_args(self): @@ -867,13 +874,11 @@ def test_no_args(self): self.assertEqual(lines[-4], "]") excepted_base = f"USER_BASE: '{site.getuserbase()}'" +\ f" ({self.exists(site.getuserbase())})" - print(excepted_base) self.assertEqual(lines[-3], excepted_base) excepted_site = f"USER_SITE: '{site.getusersitepackages()}'" +\ f" ({self.exists(site.getusersitepackages())})" self.assertEqual(lines[-2], excepted_site) self.assertEqual(lines[-1], f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}") - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") def test_unknown_args(self): diff --git a/confdefs.h b/confdefs.h new file mode 100644 index 00000000000000..d5a0cbdd928e34 --- /dev/null +++ b/confdefs.h @@ -0,0 +1,216 @@ +/* confdefs.h */ +#define _NETBSD_SOURCE 1 +#define __BSD_VISIBLE 1 +#define _DARWIN_C_SOURCE 1 +#define _PYTHONFRAMEWORK "" +#define _XOPEN_SOURCE 700 +#define _XOPEN_SOURCE_EXTENDED 1 +#define _POSIX_C_SOURCE 200809L +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_WCHAR_H 1 +#define STDC_HEADERS 1 +#define _ALL_SOURCE 1 +#define _DARWIN_C_SOURCE 1 +#define _GNU_SOURCE 1 +#define _HPUX_ALT_XOPEN_SOCKET_API 1 +#define _NETBSD_SOURCE 1 +#define _OPENBSD_SOURCE 1 +#define _POSIX_PTHREAD_SEMANTICS 1 +#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_EXT__ 1 +#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#define __STDC_WANT_LIB_EXT2__ 1 +#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#define _TANDEM_SOURCE 1 +#define __EXTENSIONS__ 1 +#define PY_SUPPORT_TIER 1 +#define STDC_HEADERS 1 +#define HAVE_ALLOCA_H 1 +#define HAVE_ASM_TYPES_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_ENDIAN_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_GRP_H 1 +#define HAVE_LANGINFO_H 1 +#define HAVE_LIBINTL_H 1 +#define HAVE_LINUX_AUXVEC_H 1 +#define HAVE_SYS_AUXV_H 1 +#define HAVE_LINUX_FS_H 1 +#define HAVE_LINUX_LIMITS_H 1 +#define HAVE_LINUX_MEMFD_H 1 +#define HAVE_LINUX_NETFILTER_IPV4_H 1 +#define HAVE_LINUX_RANDOM_H 1 +#define HAVE_LINUX_SOUNDCARD_H 1 +#define HAVE_LINUX_SCHED_H 1 +#define HAVE_LINUX_TIPC_H 1 +#define HAVE_LINUX_WAIT_H 1 +#define HAVE_NETDB_H 1 +#define HAVE_NET_ETHERNET_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_NETPACKET_PACKET_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H 1 +#define HAVE_PTY_H 1 +#define HAVE_SCHED_H 1 +#define HAVE_SETJMP_H 1 +#define HAVE_SHADOW_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_SPAWN_H 1 +#define HAVE_SYS_EPOLL_H 1 +#define HAVE_SYS_EVENTFD_H 1 +#define HAVE_SYS_FILE_H 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_PIDFD_H 1 +#define HAVE_SYS_POLL_H 1 +#define HAVE_SYS_RANDOM_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SENDFILE_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_SOUNDCARD_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_STATVFS_H 1 +#define HAVE_SYS_SYSCALL_H 1 +#define HAVE_SYS_SYSMACROS_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TIMES_H 1 +#define HAVE_SYS_TIMERFD_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_UIO_H 1 +#define HAVE_SYS_UN_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_SYS_XATTR_H 1 +#define HAVE_SYSEXITS_H 1 +#define HAVE_SYSLOG_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_UTIME_H 1 +#define HAVE_UTMP_H 1 +#define HAVE_DIRENT_H 1 +#define MAJOR_IN_SYSMACROS 1 +#define HAVE_BLUETOOTH_BLUETOOTH_H 1 +#define HAVE_NET_IF_H 1 +#define HAVE_LINUX_NETLINK_H 1 +#define HAVE_LINUX_QRTR_H 1 +#define HAVE_LINUX_VM_SOCKETS_H 1 +#define HAVE_LINUX_CAN_H 1 +#define HAVE_LINUX_CAN_BCM_H 1 +#define HAVE_LINUX_CAN_J1939_H 1 +#define HAVE_LINUX_CAN_RAW_H 1 +#define HAVE_CLOCK_T 1 +#define HAVE_MAKEDEV 1 +#define HAVE_HTOLE64 1 +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#if defined(SCO_DS) +#undef _OFF_T +#endif +#define RETSIGTYPE void +#define HAVE_SSIZE_T 1 +#define HAVE___UINT128_T 1 +#define HAVE_GCC_UINT128_T 1 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define ALIGNOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_VOID_P 8 +#define SIZEOF_SHORT 2 +#define SIZEOF_FLOAT 4 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_FPOS_T 16 +#define SIZEOF_SIZE_T 8 +#define ALIGNOF_SIZE_T 8 +#define SIZEOF_PID_T 4 +#define SIZEOF_UINTPTR_T 8 +#define ALIGNOF_MAX_ALIGN_T 16 +#define HAVE_LONG_DOUBLE 1 +#define SIZEOF_LONG_DOUBLE 16 +#define SIZEOF__BOOL 1 +#define SIZEOF_OFF_T 8 +#define SIZEOF_TIME_T 8 +#define SIZEOF_PTHREAD_T 8 +#define SIZEOF_PTHREAD_KEY_T 4 +#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 +#define PY_HAVE_PERF_TRAMPOLINE 1 +#define HAVE_LIBDL 1 +#define HAVE_EXECINFO_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_LINK_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_DLFCN_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_UUID_H 1 +#define HAVE_UUID_GENERATE_TIME_SAFE 1 +#define HAVE_FFI_PREP_CIF_VAR 1 +#define HAVE_FFI_PREP_CLOSURE_LOC 1 +#define HAVE_FFI_CLOSURE_ALLOC 1 +#define Py_FFI_SUPPORT_C_COMPLEX 1 +#define WITH_DECIMAL_CONTEXTVAR 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define PY_SQLITE_HAVE_SERIALIZE 1 +#define HAVE_GDBM_H 1 +#define HAVE_NDBM_H 1 +#define _REENTRANT 1 +#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 +#define HAVE_PTHREAD_SIGMASK 1 +#define HAVE_PTHREAD_GETCPUCLOCKID 1 +#define ENABLE_IPV6 1 +#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 +#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1 +#define WITH_DOC_STRINGS 1 +#define HAVE_STD_ATOMIC 1 +#define HAVE_BUILTIN_ATOMIC 1 +#define WITH_MIMALLOC 1 +#define WITH_PYMALLOC 1 +#define PY_COERCE_C_LOCALE 1 +#define HAVE_DLOPEN 1 +#define HAVE_DYNAMIC_LOADING 1 +#define HAVE_ACCEPT4 1 +#define HAVE_ALARM 1 +#define HAVE_BIND_TEXTDOMAIN_CODESET 1 +#define HAVE_CHMOD 1 +#define HAVE_CHOWN 1 +#define HAVE_CLOCK 1 +#define HAVE_CLOSEFROM 1 +#define HAVE_CLOSE_RANGE 1 +#define HAVE_CONFSTR 1 +#define HAVE_COPY_FILE_RANGE 1 +#define HAVE_CTERMID 1 +#define HAVE_DLADDR 1 +#define HAVE_DUP 1 +#define HAVE_DUP3 1 +#define HAVE_EXECV 1 +#define HAVE_EXPLICIT_BZERO 1 +#define HAVE_FACCESSAT 1 +#define HAVE_FCHMOD 1 +#define HAVE_FCHMODAT 1 +#define HAVE_FCHOWN 1 +#define HAVE_FCHOWNAT 1 +#define HAVE_FDOPENDIR 1 +#define HAVE_FEXECVE 1 +#define HAVE_FORK 1 diff --git a/conftest.c b/conftest.c new file mode 100644 index 00000000000000..ce214457964c27 --- /dev/null +++ b/conftest.c @@ -0,0 +1,248 @@ +/* confdefs.h */ +#define _NETBSD_SOURCE 1 +#define __BSD_VISIBLE 1 +#define _DARWIN_C_SOURCE 1 +#define _PYTHONFRAMEWORK "" +#define _XOPEN_SOURCE 700 +#define _XOPEN_SOURCE_EXTENDED 1 +#define _POSIX_C_SOURCE 200809L +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_WCHAR_H 1 +#define STDC_HEADERS 1 +#define _ALL_SOURCE 1 +#define _DARWIN_C_SOURCE 1 +#define _GNU_SOURCE 1 +#define _HPUX_ALT_XOPEN_SOCKET_API 1 +#define _NETBSD_SOURCE 1 +#define _OPENBSD_SOURCE 1 +#define _POSIX_PTHREAD_SEMANTICS 1 +#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_EXT__ 1 +#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#define __STDC_WANT_LIB_EXT2__ 1 +#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#define _TANDEM_SOURCE 1 +#define __EXTENSIONS__ 1 +#define PY_SUPPORT_TIER 1 +#define STDC_HEADERS 1 +#define HAVE_ALLOCA_H 1 +#define HAVE_ASM_TYPES_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_ENDIAN_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_GRP_H 1 +#define HAVE_LANGINFO_H 1 +#define HAVE_LIBINTL_H 1 +#define HAVE_LINUX_AUXVEC_H 1 +#define HAVE_SYS_AUXV_H 1 +#define HAVE_LINUX_FS_H 1 +#define HAVE_LINUX_LIMITS_H 1 +#define HAVE_LINUX_MEMFD_H 1 +#define HAVE_LINUX_NETFILTER_IPV4_H 1 +#define HAVE_LINUX_RANDOM_H 1 +#define HAVE_LINUX_SOUNDCARD_H 1 +#define HAVE_LINUX_SCHED_H 1 +#define HAVE_LINUX_TIPC_H 1 +#define HAVE_LINUX_WAIT_H 1 +#define HAVE_NETDB_H 1 +#define HAVE_NET_ETHERNET_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_NETPACKET_PACKET_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H 1 +#define HAVE_PTY_H 1 +#define HAVE_SCHED_H 1 +#define HAVE_SETJMP_H 1 +#define HAVE_SHADOW_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_SPAWN_H 1 +#define HAVE_SYS_EPOLL_H 1 +#define HAVE_SYS_EVENTFD_H 1 +#define HAVE_SYS_FILE_H 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_PIDFD_H 1 +#define HAVE_SYS_POLL_H 1 +#define HAVE_SYS_RANDOM_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SENDFILE_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_SOUNDCARD_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_STATVFS_H 1 +#define HAVE_SYS_SYSCALL_H 1 +#define HAVE_SYS_SYSMACROS_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TIMES_H 1 +#define HAVE_SYS_TIMERFD_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_UIO_H 1 +#define HAVE_SYS_UN_H 1 +#define HAVE_SYS_UTSNAME_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_SYS_XATTR_H 1 +#define HAVE_SYSEXITS_H 1 +#define HAVE_SYSLOG_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_UTIME_H 1 +#define HAVE_UTMP_H 1 +#define HAVE_DIRENT_H 1 +#define MAJOR_IN_SYSMACROS 1 +#define HAVE_BLUETOOTH_BLUETOOTH_H 1 +#define HAVE_NET_IF_H 1 +#define HAVE_LINUX_NETLINK_H 1 +#define HAVE_LINUX_QRTR_H 1 +#define HAVE_LINUX_VM_SOCKETS_H 1 +#define HAVE_LINUX_CAN_H 1 +#define HAVE_LINUX_CAN_BCM_H 1 +#define HAVE_LINUX_CAN_J1939_H 1 +#define HAVE_LINUX_CAN_RAW_H 1 +#define HAVE_CLOCK_T 1 +#define HAVE_MAKEDEV 1 +#define HAVE_HTOLE64 1 +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#if defined(SCO_DS) +#undef _OFF_T +#endif +#define RETSIGTYPE void +#define HAVE_SSIZE_T 1 +#define HAVE___UINT128_T 1 +#define HAVE_GCC_UINT128_T 1 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define ALIGNOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_VOID_P 8 +#define SIZEOF_SHORT 2 +#define SIZEOF_FLOAT 4 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_FPOS_T 16 +#define SIZEOF_SIZE_T 8 +#define ALIGNOF_SIZE_T 8 +#define SIZEOF_PID_T 4 +#define SIZEOF_UINTPTR_T 8 +#define ALIGNOF_MAX_ALIGN_T 16 +#define HAVE_LONG_DOUBLE 1 +#define SIZEOF_LONG_DOUBLE 16 +#define SIZEOF__BOOL 1 +#define SIZEOF_OFF_T 8 +#define SIZEOF_TIME_T 8 +#define SIZEOF_PTHREAD_T 8 +#define SIZEOF_PTHREAD_KEY_T 4 +#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 +#define PY_HAVE_PERF_TRAMPOLINE 1 +#define HAVE_LIBDL 1 +#define HAVE_EXECINFO_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_LINK_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_DLFCN_H 1 +#define HAVE_BACKTRACE 1 +#define HAVE_DLADDR1 1 +#define HAVE_UUID_H 1 +#define HAVE_UUID_GENERATE_TIME_SAFE 1 +#define HAVE_FFI_PREP_CIF_VAR 1 +#define HAVE_FFI_PREP_CLOSURE_LOC 1 +#define HAVE_FFI_CLOSURE_ALLOC 1 +#define Py_FFI_SUPPORT_C_COMPLEX 1 +#define WITH_DECIMAL_CONTEXTVAR 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define HAVE_LIBSQLITE3 1 +#define PY_SQLITE_HAVE_SERIALIZE 1 +#define HAVE_GDBM_H 1 +#define HAVE_NDBM_H 1 +#define _REENTRANT 1 +#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 +#define HAVE_PTHREAD_SIGMASK 1 +#define HAVE_PTHREAD_GETCPUCLOCKID 1 +#define ENABLE_IPV6 1 +#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 +#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1 +#define WITH_DOC_STRINGS 1 +#define HAVE_STD_ATOMIC 1 +#define HAVE_BUILTIN_ATOMIC 1 +#define WITH_MIMALLOC 1 +#define WITH_PYMALLOC 1 +#define PY_COERCE_C_LOCALE 1 +#define HAVE_DLOPEN 1 +#define HAVE_DYNAMIC_LOADING 1 +#define HAVE_ACCEPT4 1 +#define HAVE_ALARM 1 +#define HAVE_BIND_TEXTDOMAIN_CODESET 1 +#define HAVE_CHMOD 1 +#define HAVE_CHOWN 1 +#define HAVE_CLOCK 1 +#define HAVE_CLOSEFROM 1 +#define HAVE_CLOSE_RANGE 1 +#define HAVE_CONFSTR 1 +#define HAVE_COPY_FILE_RANGE 1 +#define HAVE_CTERMID 1 +#define HAVE_DLADDR 1 +#define HAVE_DUP 1 +#define HAVE_DUP3 1 +#define HAVE_EXECV 1 +#define HAVE_EXPLICIT_BZERO 1 +#define HAVE_FACCESSAT 1 +#define HAVE_FCHMOD 1 +#define HAVE_FCHMODAT 1 +#define HAVE_FCHOWN 1 +#define HAVE_FCHOWNAT 1 +#define HAVE_FDOPENDIR 1 +#define HAVE_FEXECVE 1 +#define HAVE_FORK 1 +/* end confdefs.h. */ +/* Define fpathconf to an innocuous variant, in case declares fpathconf. + For example, HP-UX 11i declares gettimeofday. */ +#define fpathconf innocuous_fpathconf + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char fpathconf (void); below. */ + +#include +#undef fpathconf + +/* 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 fpathconf (void); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_fpathconf || defined __stub___fpathconf +choke me +#endif + +int +main (void) +{ +return fpathconf (); + ; + return 0; +} From 98145f61a5e7ab65d56c51161d75745782083cf2 Mon Sep 17 00:00:00 2001 From: ggqlq Date: Thu, 8 May 2025 13:44:53 +0800 Subject: [PATCH 6/7] fix windows --- confdefs.h | 216 ---------------------------------------------- conftest.c | 248 ----------------------------------------------------- 2 files changed, 464 deletions(-) delete mode 100644 confdefs.h delete mode 100644 conftest.c diff --git a/confdefs.h b/confdefs.h deleted file mode 100644 index d5a0cbdd928e34..00000000000000 --- a/confdefs.h +++ /dev/null @@ -1,216 +0,0 @@ -/* confdefs.h */ -#define _NETBSD_SOURCE 1 -#define __BSD_VISIBLE 1 -#define _DARWIN_C_SOURCE 1 -#define _PYTHONFRAMEWORK "" -#define _XOPEN_SOURCE 700 -#define _XOPEN_SOURCE_EXTENDED 1 -#define _POSIX_C_SOURCE 200809L -#define HAVE_STDIO_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_WCHAR_H 1 -#define STDC_HEADERS 1 -#define _ALL_SOURCE 1 -#define _DARWIN_C_SOURCE 1 -#define _GNU_SOURCE 1 -#define _HPUX_ALT_XOPEN_SOCKET_API 1 -#define _NETBSD_SOURCE 1 -#define _OPENBSD_SOURCE 1 -#define _POSIX_PTHREAD_SEMANTICS 1 -#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 -#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 -#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 -#define __STDC_WANT_IEC_60559_EXT__ 1 -#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 -#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 -#define __STDC_WANT_LIB_EXT2__ 1 -#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 -#define _TANDEM_SOURCE 1 -#define __EXTENSIONS__ 1 -#define PY_SUPPORT_TIER 1 -#define STDC_HEADERS 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_ASM_TYPES_H 1 -#define HAVE_DLFCN_H 1 -#define HAVE_ENDIAN_H 1 -#define HAVE_ERRNO_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_GRP_H 1 -#define HAVE_LANGINFO_H 1 -#define HAVE_LIBINTL_H 1 -#define HAVE_LINUX_AUXVEC_H 1 -#define HAVE_SYS_AUXV_H 1 -#define HAVE_LINUX_FS_H 1 -#define HAVE_LINUX_LIMITS_H 1 -#define HAVE_LINUX_MEMFD_H 1 -#define HAVE_LINUX_NETFILTER_IPV4_H 1 -#define HAVE_LINUX_RANDOM_H 1 -#define HAVE_LINUX_SOUNDCARD_H 1 -#define HAVE_LINUX_SCHED_H 1 -#define HAVE_LINUX_TIPC_H 1 -#define HAVE_LINUX_WAIT_H 1 -#define HAVE_NETDB_H 1 -#define HAVE_NET_ETHERNET_H 1 -#define HAVE_NETINET_IN_H 1 -#define HAVE_NETPACKET_PACKET_H 1 -#define HAVE_POLL_H 1 -#define HAVE_PTHREAD_H 1 -#define HAVE_PTY_H 1 -#define HAVE_SCHED_H 1 -#define HAVE_SETJMP_H 1 -#define HAVE_SHADOW_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_SPAWN_H 1 -#define HAVE_SYS_EPOLL_H 1 -#define HAVE_SYS_EVENTFD_H 1 -#define HAVE_SYS_FILE_H 1 -#define HAVE_SYS_IOCTL_H 1 -#define HAVE_SYS_MMAN_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_PIDFD_H 1 -#define HAVE_SYS_POLL_H 1 -#define HAVE_SYS_RANDOM_H 1 -#define HAVE_SYS_RESOURCE_H 1 -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SYS_SENDFILE_H 1 -#define HAVE_SYS_SOCKET_H 1 -#define HAVE_SYS_SOUNDCARD_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_STATVFS_H 1 -#define HAVE_SYS_SYSCALL_H 1 -#define HAVE_SYS_SYSMACROS_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_TIMES_H 1 -#define HAVE_SYS_TIMERFD_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_UIO_H 1 -#define HAVE_SYS_UN_H 1 -#define HAVE_SYS_UTSNAME_H 1 -#define HAVE_SYS_WAIT_H 1 -#define HAVE_SYS_XATTR_H 1 -#define HAVE_SYSEXITS_H 1 -#define HAVE_SYSLOG_H 1 -#define HAVE_TERMIOS_H 1 -#define HAVE_UTIME_H 1 -#define HAVE_UTMP_H 1 -#define HAVE_DIRENT_H 1 -#define MAJOR_IN_SYSMACROS 1 -#define HAVE_BLUETOOTH_BLUETOOTH_H 1 -#define HAVE_NET_IF_H 1 -#define HAVE_LINUX_NETLINK_H 1 -#define HAVE_LINUX_QRTR_H 1 -#define HAVE_LINUX_VM_SOCKETS_H 1 -#define HAVE_LINUX_CAN_H 1 -#define HAVE_LINUX_CAN_BCM_H 1 -#define HAVE_LINUX_CAN_J1939_H 1 -#define HAVE_LINUX_CAN_RAW_H 1 -#define HAVE_CLOCK_T 1 -#define HAVE_MAKEDEV 1 -#define HAVE_HTOLE64 1 -#define _LARGEFILE_SOURCE 1 -#define _FILE_OFFSET_BITS 64 -#if defined(SCO_DS) -#undef _OFF_T -#endif -#define RETSIGTYPE void -#define HAVE_SSIZE_T 1 -#define HAVE___UINT128_T 1 -#define HAVE_GCC_UINT128_T 1 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 8 -#define ALIGNOF_LONG 8 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_VOID_P 8 -#define SIZEOF_SHORT 2 -#define SIZEOF_FLOAT 4 -#define SIZEOF_DOUBLE 8 -#define SIZEOF_FPOS_T 16 -#define SIZEOF_SIZE_T 8 -#define ALIGNOF_SIZE_T 8 -#define SIZEOF_PID_T 4 -#define SIZEOF_UINTPTR_T 8 -#define ALIGNOF_MAX_ALIGN_T 16 -#define HAVE_LONG_DOUBLE 1 -#define SIZEOF_LONG_DOUBLE 16 -#define SIZEOF__BOOL 1 -#define SIZEOF_OFF_T 8 -#define SIZEOF_TIME_T 8 -#define SIZEOF_PTHREAD_T 8 -#define SIZEOF_PTHREAD_KEY_T 4 -#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 -#define PY_HAVE_PERF_TRAMPOLINE 1 -#define HAVE_LIBDL 1 -#define HAVE_EXECINFO_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_LINK_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_DLFCN_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_UUID_H 1 -#define HAVE_UUID_GENERATE_TIME_SAFE 1 -#define HAVE_FFI_PREP_CIF_VAR 1 -#define HAVE_FFI_PREP_CLOSURE_LOC 1 -#define HAVE_FFI_CLOSURE_ALLOC 1 -#define Py_FFI_SUPPORT_C_COMPLEX 1 -#define WITH_DECIMAL_CONTEXTVAR 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define PY_SQLITE_HAVE_SERIALIZE 1 -#define HAVE_GDBM_H 1 -#define HAVE_NDBM_H 1 -#define _REENTRANT 1 -#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 -#define HAVE_PTHREAD_SIGMASK 1 -#define HAVE_PTHREAD_GETCPUCLOCKID 1 -#define ENABLE_IPV6 1 -#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 -#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1 -#define WITH_DOC_STRINGS 1 -#define HAVE_STD_ATOMIC 1 -#define HAVE_BUILTIN_ATOMIC 1 -#define WITH_MIMALLOC 1 -#define WITH_PYMALLOC 1 -#define PY_COERCE_C_LOCALE 1 -#define HAVE_DLOPEN 1 -#define HAVE_DYNAMIC_LOADING 1 -#define HAVE_ACCEPT4 1 -#define HAVE_ALARM 1 -#define HAVE_BIND_TEXTDOMAIN_CODESET 1 -#define HAVE_CHMOD 1 -#define HAVE_CHOWN 1 -#define HAVE_CLOCK 1 -#define HAVE_CLOSEFROM 1 -#define HAVE_CLOSE_RANGE 1 -#define HAVE_CONFSTR 1 -#define HAVE_COPY_FILE_RANGE 1 -#define HAVE_CTERMID 1 -#define HAVE_DLADDR 1 -#define HAVE_DUP 1 -#define HAVE_DUP3 1 -#define HAVE_EXECV 1 -#define HAVE_EXPLICIT_BZERO 1 -#define HAVE_FACCESSAT 1 -#define HAVE_FCHMOD 1 -#define HAVE_FCHMODAT 1 -#define HAVE_FCHOWN 1 -#define HAVE_FCHOWNAT 1 -#define HAVE_FDOPENDIR 1 -#define HAVE_FEXECVE 1 -#define HAVE_FORK 1 diff --git a/conftest.c b/conftest.c deleted file mode 100644 index ce214457964c27..00000000000000 --- a/conftest.c +++ /dev/null @@ -1,248 +0,0 @@ -/* confdefs.h */ -#define _NETBSD_SOURCE 1 -#define __BSD_VISIBLE 1 -#define _DARWIN_C_SOURCE 1 -#define _PYTHONFRAMEWORK "" -#define _XOPEN_SOURCE 700 -#define _XOPEN_SOURCE_EXTENDED 1 -#define _POSIX_C_SOURCE 200809L -#define HAVE_STDIO_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_WCHAR_H 1 -#define STDC_HEADERS 1 -#define _ALL_SOURCE 1 -#define _DARWIN_C_SOURCE 1 -#define _GNU_SOURCE 1 -#define _HPUX_ALT_XOPEN_SOCKET_API 1 -#define _NETBSD_SOURCE 1 -#define _OPENBSD_SOURCE 1 -#define _POSIX_PTHREAD_SEMANTICS 1 -#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 -#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 -#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 -#define __STDC_WANT_IEC_60559_EXT__ 1 -#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 -#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 -#define __STDC_WANT_LIB_EXT2__ 1 -#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 -#define _TANDEM_SOURCE 1 -#define __EXTENSIONS__ 1 -#define PY_SUPPORT_TIER 1 -#define STDC_HEADERS 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_ASM_TYPES_H 1 -#define HAVE_DLFCN_H 1 -#define HAVE_ENDIAN_H 1 -#define HAVE_ERRNO_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_GRP_H 1 -#define HAVE_LANGINFO_H 1 -#define HAVE_LIBINTL_H 1 -#define HAVE_LINUX_AUXVEC_H 1 -#define HAVE_SYS_AUXV_H 1 -#define HAVE_LINUX_FS_H 1 -#define HAVE_LINUX_LIMITS_H 1 -#define HAVE_LINUX_MEMFD_H 1 -#define HAVE_LINUX_NETFILTER_IPV4_H 1 -#define HAVE_LINUX_RANDOM_H 1 -#define HAVE_LINUX_SOUNDCARD_H 1 -#define HAVE_LINUX_SCHED_H 1 -#define HAVE_LINUX_TIPC_H 1 -#define HAVE_LINUX_WAIT_H 1 -#define HAVE_NETDB_H 1 -#define HAVE_NET_ETHERNET_H 1 -#define HAVE_NETINET_IN_H 1 -#define HAVE_NETPACKET_PACKET_H 1 -#define HAVE_POLL_H 1 -#define HAVE_PTHREAD_H 1 -#define HAVE_PTY_H 1 -#define HAVE_SCHED_H 1 -#define HAVE_SETJMP_H 1 -#define HAVE_SHADOW_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_SPAWN_H 1 -#define HAVE_SYS_EPOLL_H 1 -#define HAVE_SYS_EVENTFD_H 1 -#define HAVE_SYS_FILE_H 1 -#define HAVE_SYS_IOCTL_H 1 -#define HAVE_SYS_MMAN_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_PIDFD_H 1 -#define HAVE_SYS_POLL_H 1 -#define HAVE_SYS_RANDOM_H 1 -#define HAVE_SYS_RESOURCE_H 1 -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SYS_SENDFILE_H 1 -#define HAVE_SYS_SOCKET_H 1 -#define HAVE_SYS_SOUNDCARD_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_STATVFS_H 1 -#define HAVE_SYS_SYSCALL_H 1 -#define HAVE_SYS_SYSMACROS_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_SYS_TIMES_H 1 -#define HAVE_SYS_TIMERFD_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_UIO_H 1 -#define HAVE_SYS_UN_H 1 -#define HAVE_SYS_UTSNAME_H 1 -#define HAVE_SYS_WAIT_H 1 -#define HAVE_SYS_XATTR_H 1 -#define HAVE_SYSEXITS_H 1 -#define HAVE_SYSLOG_H 1 -#define HAVE_TERMIOS_H 1 -#define HAVE_UTIME_H 1 -#define HAVE_UTMP_H 1 -#define HAVE_DIRENT_H 1 -#define MAJOR_IN_SYSMACROS 1 -#define HAVE_BLUETOOTH_BLUETOOTH_H 1 -#define HAVE_NET_IF_H 1 -#define HAVE_LINUX_NETLINK_H 1 -#define HAVE_LINUX_QRTR_H 1 -#define HAVE_LINUX_VM_SOCKETS_H 1 -#define HAVE_LINUX_CAN_H 1 -#define HAVE_LINUX_CAN_BCM_H 1 -#define HAVE_LINUX_CAN_J1939_H 1 -#define HAVE_LINUX_CAN_RAW_H 1 -#define HAVE_CLOCK_T 1 -#define HAVE_MAKEDEV 1 -#define HAVE_HTOLE64 1 -#define _LARGEFILE_SOURCE 1 -#define _FILE_OFFSET_BITS 64 -#if defined(SCO_DS) -#undef _OFF_T -#endif -#define RETSIGTYPE void -#define HAVE_SSIZE_T 1 -#define HAVE___UINT128_T 1 -#define HAVE_GCC_UINT128_T 1 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 8 -#define ALIGNOF_LONG 8 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_VOID_P 8 -#define SIZEOF_SHORT 2 -#define SIZEOF_FLOAT 4 -#define SIZEOF_DOUBLE 8 -#define SIZEOF_FPOS_T 16 -#define SIZEOF_SIZE_T 8 -#define ALIGNOF_SIZE_T 8 -#define SIZEOF_PID_T 4 -#define SIZEOF_UINTPTR_T 8 -#define ALIGNOF_MAX_ALIGN_T 16 -#define HAVE_LONG_DOUBLE 1 -#define SIZEOF_LONG_DOUBLE 16 -#define SIZEOF__BOOL 1 -#define SIZEOF_OFF_T 8 -#define SIZEOF_TIME_T 8 -#define SIZEOF_PTHREAD_T 8 -#define SIZEOF_PTHREAD_KEY_T 4 -#define PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT 1 -#define PY_HAVE_PERF_TRAMPOLINE 1 -#define HAVE_LIBDL 1 -#define HAVE_EXECINFO_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_LINK_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_DLFCN_H 1 -#define HAVE_BACKTRACE 1 -#define HAVE_DLADDR1 1 -#define HAVE_UUID_H 1 -#define HAVE_UUID_GENERATE_TIME_SAFE 1 -#define HAVE_FFI_PREP_CIF_VAR 1 -#define HAVE_FFI_PREP_CLOSURE_LOC 1 -#define HAVE_FFI_CLOSURE_ALLOC 1 -#define Py_FFI_SUPPORT_C_COMPLEX 1 -#define WITH_DECIMAL_CONTEXTVAR 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define HAVE_LIBSQLITE3 1 -#define PY_SQLITE_HAVE_SERIALIZE 1 -#define HAVE_GDBM_H 1 -#define HAVE_NDBM_H 1 -#define _REENTRANT 1 -#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 -#define HAVE_PTHREAD_SIGMASK 1 -#define HAVE_PTHREAD_GETCPUCLOCKID 1 -#define ENABLE_IPV6 1 -#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 -#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1 -#define WITH_DOC_STRINGS 1 -#define HAVE_STD_ATOMIC 1 -#define HAVE_BUILTIN_ATOMIC 1 -#define WITH_MIMALLOC 1 -#define WITH_PYMALLOC 1 -#define PY_COERCE_C_LOCALE 1 -#define HAVE_DLOPEN 1 -#define HAVE_DYNAMIC_LOADING 1 -#define HAVE_ACCEPT4 1 -#define HAVE_ALARM 1 -#define HAVE_BIND_TEXTDOMAIN_CODESET 1 -#define HAVE_CHMOD 1 -#define HAVE_CHOWN 1 -#define HAVE_CLOCK 1 -#define HAVE_CLOSEFROM 1 -#define HAVE_CLOSE_RANGE 1 -#define HAVE_CONFSTR 1 -#define HAVE_COPY_FILE_RANGE 1 -#define HAVE_CTERMID 1 -#define HAVE_DLADDR 1 -#define HAVE_DUP 1 -#define HAVE_DUP3 1 -#define HAVE_EXECV 1 -#define HAVE_EXPLICIT_BZERO 1 -#define HAVE_FACCESSAT 1 -#define HAVE_FCHMOD 1 -#define HAVE_FCHMODAT 1 -#define HAVE_FCHOWN 1 -#define HAVE_FCHOWNAT 1 -#define HAVE_FDOPENDIR 1 -#define HAVE_FEXECVE 1 -#define HAVE_FORK 1 -/* end confdefs.h. */ -/* Define fpathconf to an innocuous variant, in case declares fpathconf. - For example, HP-UX 11i declares gettimeofday. */ -#define fpathconf innocuous_fpathconf - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char fpathconf (void); below. */ - -#include -#undef fpathconf - -/* 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 fpathconf (void); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_fpathconf || defined __stub___fpathconf -choke me -#endif - -int -main (void) -{ -return fpathconf (); - ; - return 0; -} From d36397b9b6310196b3fab5b06409d5f20225a4f6 Mon Sep 17 00:00:00 2001 From: ggqlq Date: Tue, 13 May 2025 13:36:29 +0800 Subject: [PATCH 7/7] update --- Lib/test/test_site.py | 58 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 39b2f0d5291901..7cf31b949d0914 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -13,6 +13,7 @@ from test.support import socket_helper from test.support import captured_stderr from test.support.os_helper import TESTFN, EnvironmentVarGuard +from test.support.script_helper import spawn_python, kill_python import ast import builtins import glob @@ -808,23 +809,24 @@ def test_underpth_dll_file(self): class CommandLineTests(unittest.TestCase): def exists(self, path): - if path is not None and os.path.isdir(path): - return "exists" - else: - return "doesn't exist" + if path is not None and os.path.isdir(path): + return "exists" + else: + return "doesn't exist" def get_excepted_output(self, *args): if len(args) == 0: user_base = site.getuserbase() user_site = site.getusersitepackages() - output = "sys.path = [\n" + output = io.StringIO() + output.write("sys.path = [\n") for dir in sys.path: - output += " %r,\n" % (dir,) - output += "]\n" - output += f"USER_BASE: {user_base!r} ({self.exists(user_base)})\n" - output += f"USER_SITE: {user_site!r} ({self.exists(user_site)})\n" - output += f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE!r}\n" - return 0, dedent(output).strip() + output.write(" %r,\n" % (dir,)) + output.write("]\n") + output.write(f"USER_BASE: {user_base} ({self.exists(user_base)})\n") + output.write(f"USER_SITE: {user_site} ({self.exists(user_site)})\n") + output.write(f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}\n") + return 0, dedent(output.getvalue()).strip() buffer = [] if '--user-base' in args: @@ -846,25 +848,19 @@ def get_excepted_output(self, *args): return 10, None def invoke_command_line(self, *args): - args = [sys.executable, "-m", "site", *args] - env = os.environ.copy() - env["PYTHONUTF8"] = "1" - env["PYTHONIOENCODING"] = "utf-8" - - proc = subprocess.Popen(args, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - env=env, - encoding='utf-8', - errors='replace') - proc.wait() - output = proc.stdout.read() + args = ["-m", "site", *args] + + with EnvironmentVarGuard() as env: + env["PYTHONUTF8"] = "1" + env["PYTHONIOENCODING"] = "utf-8" + proc = spawn_python(*args, text=True, env=env, + encoding='utf-8', errors='replace') + + output = kill_python(proc) return_code = proc.returncode - proc.stdout.close() return return_code, os.path.normpath(dedent(output).strip()) - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") + @support.requires_subprocess() def test_no_args(self): return_code, output = self.invoke_command_line() excepted_return_code, _ = self.get_excepted_output() @@ -880,14 +876,14 @@ def test_no_args(self): self.assertEqual(lines[-2], excepted_site) self.assertEqual(lines[-1], f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}") - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") + @support.requires_subprocess() def test_unknown_args(self): return_code, output = self.invoke_command_line("--unknown-arg") excepted_return_code, _ = self.get_excepted_output("--unknown-arg") self.assertEqual(return_code, excepted_return_code) self.assertIn('[--user-base] [--user-site]', output) - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") + @support.requires_subprocess() def test_base_arg(self): return_code, output = self.invoke_command_line("--user-base") excepted = self.get_excepted_output("--user-base") @@ -895,7 +891,7 @@ def test_base_arg(self): self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") + @support.requires_subprocess() def test_site_arg(self): return_code, output = self.invoke_command_line("--user-site") excepted = self.get_excepted_output("--user-site") @@ -903,7 +899,7 @@ def test_site_arg(self): self.assertEqual(return_code, excepted_return_code) self.assertEqual(output, excepted_output) - @unittest.skipIf(sys.platform == 'wasi', "Popen not supported on WASI") + @support.requires_subprocess() def test_both_args(self): return_code, output = self.invoke_command_line("--user-base", "--user-site") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy