Python-checkins
Threads by month
- ----- 2024 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
November 2021
- 1 participants
- 444 discussions
24 Nov '21
https://github.com/python/cpython/commit/abfc794bbf2c6a0939ddd81b6e700c4694…
commit: abfc794bbf2c6a0939ddd81b6e700c46944ba87a
branch: main
author: Pablo Galindo Salgado <Pablogsal(a)gmail.com>
committer: pablogsal <Pablogsal(a)gmail.com>
date: 2021-11-24T18:30:03Z
summary:
bpo-45822: Minor cleanups to the test_Py_CompileString test (GH-29750)
files:
M Lib/test/test_capi.py
M Modules/_testcapimodule.c
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 5e1619bf7dc9d..d51247003ded1 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -635,6 +635,14 @@ def test_pyobject_bytes_from_null(self):
s = _testcapi.pyobject_bytes_from_null()
self.assertEqual(s, b'<NULL>')
+ def test_Py_CompileString(self):
+ # Check that Py_CompileString respects the coding cookie
+ _compile = _testcapi.Py_CompileString
+ code = b"# -*- coding: latin1 -*-\nprint('\xc2\xa4')\n"
+ result = _compile(code)
+ expected = compile(code, "<string>", "exec")
+ self.assertEqual(result.co_consts, expected.co_consts)
+
class TestPendingCalls(unittest.TestCase):
@@ -1017,14 +1025,6 @@ def test_state_access(self):
with self.assertRaises(TypeError):
increment_count(1, 2, 3)
- def test_Py_CompileString(self):
- # Check that Py_CompileString respects the coding cookie
- _compile = _testcapi.Py_CompileString
- code = b"# -*- coding: latin1 -*-\nprint('\xc2\xa4')\n"
- result = _compile(code)
- expected = compile(code, "<string>", "exec")
- self.assertEqual(result.co_consts, expected.co_consts)
-
if __name__ == "__main__":
unittest.main()
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index c9ba148973162..0216c985415ce 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -391,7 +391,7 @@ pycompilestring(PyObject* self, PyObject *obj) {
if (the_string == NULL) {
return NULL;
}
- return Py_CompileString(the_string, "blech", Py_file_input);
+ return Py_CompileString(the_string, "<string>", Py_file_input);
}
static PyObject*
1
0
https://github.com/python/cpython/commit/b30bf4520ae9d6e7eca09d812dd8a86c02…
commit: b30bf4520ae9d6e7eca09d812dd8a86c020b9202
branch: main
author: Christian Heimes <christian(a)python.org>
committer: tiran <christian(a)python.org>
date: 2021-11-24T18:53:33+01:00
summary:
bpo-45881: Use CC from env first for cross building (GH-29752)
files:
A Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst
M setup.py
diff --git a/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst b/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst
new file mode 100644
index 0000000000000..b697658cf3aaa
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst
@@ -0,0 +1,2 @@
+``setup.py`` now uses ``CC`` from environment first to discover multiarch
+and cross compile paths.
diff --git a/setup.py b/setup.py
index 932667ad0c2ff..79f8f4ef50817 100644
--- a/setup.py
+++ b/setup.py
@@ -84,6 +84,9 @@ def get_platform():
MACOS = (HOST_PLATFORM == 'darwin')
AIX = (HOST_PLATFORM.startswith('aix'))
VXWORKS = ('vxworks' in HOST_PLATFORM)
+CC = os.environ.get("CC")
+if not CC:
+ CC = sysconfig.get_config_var("CC")
SUMMARY = """
@@ -556,6 +559,9 @@ def set_compiler_executables(self):
def build_extensions(self):
self.set_srcdir()
+ self.set_compiler_executables()
+ self.configure_compiler()
+ self.init_inc_lib_dirs()
# Detect which modules should be compiled
self.detect_modules()
@@ -565,7 +571,6 @@ def build_extensions(self):
self.update_sources_depends()
mods_built, mods_disabled = self.handle_configured_extensions()
- self.set_compiler_executables()
if LIST_MODULE_NAMES:
for ext in self.extensions:
@@ -751,12 +756,11 @@ def check_extension_import(self, ext):
def add_multiarch_paths(self):
# Debian/Ubuntu multiarch support.
# https://wiki.ubuntu.com/MultiarchSpec
- cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'multiarch')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
ret = run_command(
- '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
+ '%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile))
multiarch_path_component = ''
try:
if ret == 0:
@@ -818,11 +822,10 @@ def add_search_path(line):
d = os.path.normpath(d)
add_dir_to_list(self.compiler.library_dirs, d)
- cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'wrccpaths')
os.makedirs(self.build_temp, exist_ok=True)
try:
- ret = run_command('%s --print-search-dirs >%s' % (cc, tmpfile))
+ ret = run_command('%s --print-search-dirs >%s' % (CC, tmpfile))
if ret:
return
with open(tmpfile) as fp:
@@ -840,11 +843,10 @@ def add_search_path(line):
pass
def add_cross_compiling_paths(self):
- cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'ccpaths')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
- ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
+ ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (CC, tmpfile))
is_gcc = False
is_clang = False
in_incdirs = False
@@ -1407,9 +1409,6 @@ def detect_modules(self):
# remove dummy extension
self.extensions = []
- self.configure_compiler()
- self.init_inc_lib_dirs()
-
# Some C extensions are built by entries in Modules/Setup.bootstrap.
# These are extensions are required to bootstrap the interpreter or
# build process.
1
0
https://github.com/python/cpython/commit/64c3807da93fc3e0c15bc376f220b2d245…
commit: 64c3807da93fc3e0c15bc376f220b2d24551023e
branch: main
author: Christian Heimes <christian(a)python.org>
committer: tiran <christian(a)python.org>
date: 2021-11-24T10:47:22+01:00
summary:
bpo-45847: Fix _crypt detection on Ubuntu (GH-29743)
files:
M configure
M configure.ac
diff --git a/configure b/configure
index d2d79920d08ff..abfda2b00de74 100755
--- a/configure
+++ b/configure
@@ -15805,7 +15805,7 @@ save_LIBS=$LIBS
CPPFLAGS="$LIBCRYPT_CFLAGS $CFLAGS"
- LDFLAGS="$LIBCRYPT_LIBS $LDFLAGS"
+ LIBS="$LIBCRYPT_LIBS $LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt or crypt_r" >&5
$as_echo_n "checking for crypt or crypt_r... " >&6; }
if ${ac_cv_crypt_crypt+:} false; then :
diff --git a/configure.ac b/configure.ac
index 4961e5a2553c3..1853baa5a8e8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4243,7 +4243,7 @@ PKG_CHECK_MODULES([LIBCRYPT], [libxcrypt >= 3.1.1], [
WITH_SAVE_ENV([
CPPFLAGS="$LIBCRYPT_CFLAGS $CFLAGS"
- LDFLAGS="$LIBCRYPT_LIBS $LDFLAGS"
+ LIBS="$LIBCRYPT_LIBS $LIBS"
AC_CACHE_CHECK([for crypt or crypt_r], [ac_cv_crypt_crypt], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_CRYPT_H
1
0
https://github.com/python/cpython/commit/8af6481f6b7d43646c47d8fa6cc6d5eb46…
commit: 8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f
branch: main
author: Christian Heimes <christian(a)python.org>
committer: tiran <christian(a)python.org>
date: 2021-11-24T10:20:37+01:00
summary:
bpo-45847: Port _uuid to PY_STDLIB_MOD (GH-29741)
files:
M Modules/Setup.stdlib.in
M Modules/_uuidmodule.c
M configure
M configure.ac
M pyconfig.h.in
M setup.py
diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in
index e999775caf3f7..eadd1619a3b38 100644
--- a/Modules/Setup.stdlib.in
+++ b/Modules/Setup.stdlib.in
@@ -136,6 +136,8 @@
# needs -lcrypt
@MODULE__HASHLIB_TRUE@_hashlib _hashopenssl.c
+# Linux: -luuid, BSD/AIX: libc's uuid_create()
+@MODULE__UUID_TRUE@_uuid _uuidmodule.c
############################################################################
# macOS specific modules
diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c
index 3f33e22a055c6..eae38f5c98cc7 100644
--- a/Modules/_uuidmodule.c
+++ b/Modules/_uuidmodule.c
@@ -6,10 +6,12 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#ifdef HAVE_UUID_UUID_H
-#include <uuid/uuid.h>
-#elif defined(HAVE_UUID_H)
-#include <uuid.h>
+#if defined(HAVE_UUID_H)
+ // AIX, FreeBSD, libuuid with pkgconf
+ #include <uuid.h>
+#elif defined(HAVE_UUID_UUID_H)
+ // libuuid without pkgconf
+ #include <uuid/uuid.h>
#endif
#ifdef MS_WINDOWS
diff --git a/configure b/configure
index 70c94a4e24d60..d2d79920d08ff 100755
--- a/configure
+++ b/configure
@@ -654,6 +654,8 @@ MODULE_BINASCII_FALSE
MODULE_BINASCII_TRUE
MODULE_ZLIB_FALSE
MODULE_ZLIB_TRUE
+MODULE__UUID_FALSE
+MODULE__UUID_TRUE
MODULE__SQLITE3_FALSE
MODULE__SQLITE3_TRUE
MODULE_NIS_FALSE
@@ -827,6 +829,8 @@ LIBEXPAT_INTERNAL
LIBEXPAT_LDFLAGS
LIBEXPAT_CFLAGS
TZPATH
+LIBUUID_LIBS
+LIBUUID_CFLAGS
SHLIBS
CFLAGSFORSHARED
LINKFORSHARED
@@ -1046,6 +1050,8 @@ LIBS
CPPFLAGS
CPP
PROFILE_TASK
+LIBUUID_CFLAGS
+LIBUUID_LIBS
LIBNSL_CFLAGS
LIBNSL_LIBS
LIBSQLITE3_CFLAGS
@@ -1833,6 +1839,10 @@ Some influential environment variables:
CPP C preprocessor
PROFILE_TASK
Python args for PGO generation task
+ LIBUUID_CFLAGS
+ C compiler flags for LIBUUID, overriding pkg-config
+ LIBUUID_LIBS
+ linker flags for LIBUUID, overriding pkg-config
LIBNSL_CFLAGS
C compiler flags for LIBNSL, overriding pkg-config
LIBNSL_LIBS linker flags for LIBNSL, overriding pkg-config
@@ -10371,62 +10381,252 @@ _ACEOF
fi
# Dynamic linking for HP-UX
-# checks for uuid.h location
-for ac_header in uuid/uuid.h uuid.h
+
+have_uuid=missing
+
+for ac_header in uuid.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"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default"
+if test "x$ac_cv_header_uuid_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define HAVE_UUID_H 1
_ACEOF
+ for ac_func in uuid_create uuid_enc_be
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+ have_uuid=yes
+ LIBUUID_CFLAGS=
+ LIBUUID_LIBS=
+
+fi
+done
+
+
fi
done
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe" >&5
-$as_echo_n "checking for uuid_generate_time_safe... " >&6; }
-if ${ac_cv_lib_uuid_uuid_generate_time_safe+:} false; then :
- $as_echo_n "(cached) " >&6
+
+
+
+
+if test "x$have_uuid" = xmissing; then :
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUUID" >&5
+$as_echo_n "checking for LIBUUID... " >&6; }
+
+if test -n "$LIBUUID_CFLAGS"; then
+ pkg_cv_LIBUUID_CFLAGS="$LIBUUID_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_LIBUUID_CFLAGS=`$PKG_CONFIG --cflags "uuid >= 2.20" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$LIBUUID_LIBS"; then
+ pkg_cv_LIBUUID_LIBS="$LIBUUID_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 2.20\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "uuid >= 2.20") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_LIBUUID_LIBS=`$PKG_CONFIG --libs "uuid >= 2.20" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ LIBUUID_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "uuid >= 2.20" 2>&1`
+ else
+ LIBUUID_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "uuid >= 2.20" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$LIBUUID_PKG_ERRORS" >&5
+
+
+ LIBUUID_LIBS="-luuid"
+ LIBUUID_CFLAGS=
+ have_uuid=no
+ for ac_header in uuid/uuid.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default"
+if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UUID_UUID_H 1
+_ACEOF
+
+ save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
+save_LIBS=$LIBS
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5
+$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; }
+if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-luuid $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <uuid/uuid.h>
+
+/* 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 uuid_generate_time ();
int
main ()
{
+return uuid_generate_time ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_uuid_uuid_generate_time=yes
+else
+ ac_cv_lib_uuid_uuid_generate_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5
+$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; }
+if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then :
+ have_uuid=yes
+fi
-#ifndef uuid_generate_time_safe
-void *x = uuid_generate_time_safe
-#endif
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
+LIBS=$save_LIBS
+
+
+ save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
+save_LIBS=$LIBS
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe in -luuid" >&5
+$as_echo_n "checking for uuid_generate_time_safe in -luuid... " >&6; }
+if ${ac_cv_lib_uuid_uuid_generate_time_safe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-luuid $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* 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 uuid_generate_time_safe ();
+int
+main ()
+{
+return uuid_generate_time_safe ();
;
return 0;
}
_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_uuid_uuid_generate_time_safe=yes
else
ac_cv_lib_uuid_uuid_generate_time_safe=no
fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time_safe" >&5
$as_echo "$ac_cv_lib_uuid_uuid_generate_time_safe" >&6; }
if test "x$ac_cv_lib_uuid_uuid_generate_time_safe" = xyes; then :
+ have_uuid=yes
+ $as_echo "#define HAVE_UUID_GENERATE_TIME_SAFE 1" >>confdefs.h
+
+
+fi
+
+
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
+LIBS=$save_LIBS
-$as_echo "#define HAVE_UUID_GENERATE_TIME_SAFE 1" >>confdefs.h
fi
-# check for libuuid from util-linux
+done
+
+
+
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ LIBUUID_LIBS="-luuid"
+ LIBUUID_CFLAGS=
+ have_uuid=no
+ for ac_header in uuid/uuid.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default"
+if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UUID_UUID_H 1
+_ACEOF
+
+ save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
save_LIBS=$LIBS
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time in -luuid" >&5
$as_echo_n "checking for uuid_generate_time in -luuid... " >&6; }
if ${ac_cv_lib_uuid_uuid_generate_time+:} false; then :
@@ -10464,33 +10664,96 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time" >&5
$as_echo "$ac_cv_lib_uuid_uuid_generate_time" >&6; }
if test "x$ac_cv_lib_uuid_uuid_generate_time" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUUID 1
+ have_uuid=yes
+fi
+
+
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
+LIBS=$save_LIBS
+
+
+ save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
+save_LIBS=$LIBS
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe in -luuid" >&5
+$as_echo_n "checking for uuid_generate_time_safe in -luuid... " >&6; }
+if ${ac_cv_lib_uuid_uuid_generate_time_safe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-luuid $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* 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 uuid_generate_time_safe ();
+int
+main ()
+{
+return uuid_generate_time_safe ();
+ ;
+ return 0;
+}
_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_uuid_uuid_generate_time_safe=yes
+else
+ ac_cv_lib_uuid_uuid_generate_time_safe=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate_time_safe" >&5
+$as_echo "$ac_cv_lib_uuid_uuid_generate_time_safe" >&6; }
+if test "x$ac_cv_lib_uuid_uuid_generate_time_safe" = xyes; then :
+
+ have_uuid=yes
+ $as_echo "#define HAVE_UUID_GENERATE_TIME_SAFE 1" >>confdefs.h
- LIBS="-luuid $LIBS"
fi
+
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
LIBS=$save_LIBS
-# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
-# FreeBSD and OpenBSD provides support in libc as well.
-# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
-# stream in big-endian byte-order
-for ac_func in uuid_create uuid_enc_be
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
+
fi
+
done
+
+else
+ LIBUUID_CFLAGS=$pkg_cv_LIBUUID_CFLAGS
+ LIBUUID_LIBS=$pkg_cv_LIBUUID_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+ have_uuid=yes
+ $as_echo "#define HAVE_UUID_H 1" >>confdefs.h
+
+ $as_echo "#define HAVE_UUID_GENERATE_TIME_SAFE 1" >>confdefs.h
+
+
+fi
+
+fi
+
# 'Real Time' functions on Solaris
# posix4 on Solaris 2.6
# pthread (first!) on Linux
@@ -21905,6 +22168,42 @@ fi
$as_echo "$py_cv_module__sqlite3" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _uuid" >&5
+$as_echo_n "checking for stdlib extension module _uuid... " >&6; }
+ case $py_stdlib_not_available in #(
+ *_uuid*) :
+ py_cv_module__uuid=n/a ;; #(
+ *) :
+ if true; then :
+ if test "$have_uuid" = "yes"; then :
+ py_cv_module__uuid=yes
+else
+ py_cv_module__uuid=missing
+fi
+else
+ py_cv_module__uuid=disabled
+fi
+ ;;
+esac
+ as_fn_append MODULE_BLOCK "MODULE__UUID=$py_cv_module__uuid$as_nl"
+ if test "x$py_cv_module__uuid" = xyes; then :
+
+ as_fn_append MODULE_BLOCK "MODULE__UUID_CFLAGS=$LIBUUID_CFLAGS$as_nl"
+ as_fn_append MODULE_BLOCK "MODULE__UUID_LDFLAGS=$LIBUUID_LIBS$as_nl"
+
+fi
+ if test "$py_cv_module__uuid" = yes; then
+ MODULE__UUID_TRUE=
+ MODULE__UUID_FALSE='#'
+else
+ MODULE__UUID_TRUE='#'
+ MODULE__UUID_FALSE=
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__uuid" >&5
+$as_echo "$py_cv_module__uuid" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module zlib" >&5
$as_echo_n "checking for stdlib extension module zlib... " >&6; }
@@ -22774,6 +23073,10 @@ if test -z "${MODULE__SQLITE3_TRUE}" && test -z "${MODULE__SQLITE3_FALSE}"; then
as_fn_error $? "conditional \"MODULE__SQLITE3\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${MODULE__UUID_TRUE}" && test -z "${MODULE__UUID_FALSE}"; then
+ as_fn_error $? "conditional \"MODULE__UUID\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${MODULE_ZLIB_TRUE}" && test -z "${MODULE_ZLIB_FALSE}"; then
as_fn_error $? "conditional \"MODULE_ZLIB\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index a161a8cf88545..4961e5a2553c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2871,31 +2871,51 @@ AC_CHECK_LIB(sendfile, sendfile)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
-# checks for uuid.h location
-AC_CHECK_HEADERS([uuid/uuid.h uuid.h])
-AC_CACHE_CHECK([for uuid_generate_time_safe], [ac_cv_lib_uuid_uuid_generate_time_safe], [
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid/uuid.h>]], [[
-#ifndef uuid_generate_time_safe
-void *x = uuid_generate_time_safe
-#endif
-]])],
-[ac_cv_lib_uuid_uuid_generate_time_safe=yes], [ac_cv_lib_uuid_uuid_generate_time_safe=no])
-])
-AS_VAR_IF([ac_cv_lib_uuid_uuid_generate_time_safe], [yes], [
- AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE, 1, [Define if uuid_generate_time_safe() exists.])
+dnl check for uuid dependencies
+AH_TEMPLATE([HAVE_UUID_H], [Define to 1 if you have the <uuid.h> header file.])
+AH_TEMPLATE([HAVE_UUID_UUID_H], [Define to 1 if you have the <uuid/uuid.h> header file.])
+AH_TEMPLATE([HAVE_UUID_GENERATE_TIME_SAFE], [Define if uuid_generate_time_safe() exists.])
+have_uuid=missing
+
+dnl AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1
+dnl (anno 2007). FreeBSD and OpenBSD provides support in libc as well.
+dnl Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
+dnl stream in big-endian byte-order
+AC_CHECK_HEADERS([uuid.h], [
+ AC_CHECK_FUNCS([uuid_create uuid_enc_be], [
+ have_uuid=yes
+ LIBUUID_CFLAGS=
+ LIBUUID_LIBS=
+ ])
])
-# check for libuuid from util-linux
-save_LIBS=$LIBS
-AC_CHECK_LIB([uuid], [uuid_generate_time])
-LIBS=$save_LIBS
-
-# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
-# FreeBSD and OpenBSD provides support in libc as well.
-# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
-# stream in big-endian byte-order
-AC_CHECK_FUNCS([uuid_create uuid_enc_be])
+AS_VAR_IF([have_uuid], [missing], [
+ PKG_CHECK_MODULES(
+ [LIBUUID], [uuid >= 2.20], [
+ dnl linux-util's libuuid has uuid_generate_time_safe() since v2.20 (2011)
+ dnl and provides <uuid.h>.
+ have_uuid=yes
+ AC_DEFINE([HAVE_UUID_H], [1])
+ AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
+ ], [
+ LIBUUID_LIBS="-luuid"
+ LIBUUID_CFLAGS=
+ have_uuid=no
+ AC_CHECK_HEADERS([uuid/uuid.h], [
+ WITH_SAVE_ENV(
+ [AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes])
+ ])
+ WITH_SAVE_ENV([
+ AC_CHECK_LIB([uuid], [uuid_generate_time_safe], [
+ have_uuid=yes
+ AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
+ ])
+ ])
+ ])
+ ]
+ )
+])
# 'Real Time' functions on Solaris
# posix4 on Solaris 2.6
@@ -6299,6 +6319,9 @@ PY_STDLIB_MOD([_sqlite3],
[test "$have_sqlite3" = "yes"],
[test "$have_supported_sqlite3" = "yes"],
[$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS])
+PY_STDLIB_MOD([_uuid],
+ [], [test "$have_uuid" = "yes"],
+ [$LIBUUID_CFLAGS], [$LIBUUID_LIBS])
dnl compression libs
PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes],
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 67f27c2b17e3b..842759fb213ae 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -628,9 +628,6 @@
/* Define to 1 if you have the <libutil.h> header file. */
#undef HAVE_LIBUTIL_H
-/* Define to 1 if you have the `uuid' library (-luuid). */
-#undef HAVE_LIBUUID
-
/* Define if you have the 'link' function. */
#undef HAVE_LINK
diff --git a/setup.py b/setup.py
index 72497de5c0d3a..932667ad0c2ff 100644
--- a/setup.py
+++ b/setup.py
@@ -1401,17 +1401,7 @@ def detect_multiprocessing(self):
def detect_uuid(self):
# Build the _uuid module if possible
- uuid_h = sysconfig.get_config_var("HAVE_UUID_H")
- uuid_uuid_h = sysconfig.get_config_var("HAVE_UUID_UUID_H")
- if uuid_h or uuid_uuid_h:
- if sysconfig.get_config_var("HAVE_LIBUUID"):
- uuid_libs = ["uuid"]
- else:
- uuid_libs = []
- self.add(Extension('_uuid', ['_uuidmodule.c'],
- libraries=uuid_libs))
- else:
- self.missing.append('_uuid')
+ self.addext(Extension('_uuid', ['_uuidmodule.c']))
def detect_modules(self):
# remove dummy extension
1
0
24 Nov '21
https://github.com/python/cpython/commit/d5cd2effa69551c6bc7edfef8a414d545d…
commit: d5cd2effa69551c6bc7edfef8a414d545dea9117
branch: main
author: Jason R. Coombs <jaraco(a)jaraco.com>
committer: jaraco <jaraco(a)jaraco.com>
date: 2021-11-24T02:51:37-05:00
summary:
bpo-45514: Deprecate importlib resources legacy functions. (GH-29036)
* bpo-45514: Apply changes from importlib_resources@a3ef4128c6
* Mark legacy functions as deprecated in the docs and link to the migration docs in importlib_resources docs.
* Apply changes from importlib_resources@329ae9d5f2c.
* Indicate importlib.resources as a module.
Co-authored-by: Filipe Laíns <lains(a)riseup.net>
files:
A Misc/NEWS.d/next/Library/2021-10-18-14-25-35.bpo-45514.YmlzIl.rst
M Doc/library/importlib.rst
M Lib/importlib/_itertools.py
M Lib/importlib/_legacy.py
M Lib/test/test_importlib/resources/util.py
M Lib/test/test_importlib/test_contents.py
M Lib/test/test_importlib/test_open.py
M Lib/test/test_importlib/test_path.py
M Lib/test/test_importlib/test_read.py
M Lib/test/test_importlib/test_resource.py
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 59c8c64acdc3b..347e08e4a2846 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -917,7 +917,9 @@ not** have to exist as physical files and directories on the file system.
on `using importlib.resources
<http://importlib-resources.readthedocs.io/en/latest/using.html>`_ and
`migrating from pkg_resources to importlib.resources
- <http://importlib-resources.readthedocs.io/en/latest/migration.html>`_.
+ <http://importlib-resources.readthedocs.io/en/latest/migration.html>`_
+ and
+ `migrating legacy usage <https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-f…>`_.
Loaders that wish to support resource reading should implement a
``get_resource_reader(fullname)`` method as specified by
@@ -979,6 +981,8 @@ The following functions are available.
sub-resources (i.e. it cannot be a directory). This function returns a
``typing.BinaryIO`` instance, a binary I/O stream open for reading.
+ .. deprecated:: 3.11
+
.. function:: open_text(package, resource, encoding='utf-8', errors='strict')
@@ -994,6 +998,8 @@ The following functions are available.
This function returns a ``typing.TextIO`` instance, a text I/O stream open
for reading.
+ .. deprecated:: 3.11
+
.. function:: read_binary(package, resource)
@@ -1006,6 +1012,8 @@ The following functions are available.
sub-resources (i.e. it cannot be a directory). This function returns the
contents of the resource as :class:`bytes`.
+ .. deprecated:: 3.11
+
.. function:: read_text(package, resource, encoding='utf-8', errors='strict')
@@ -1019,6 +1027,8 @@ The following functions are available.
have the same meaning as with built-in :func:`open`. This function
returns the contents of the resource as :class:`str`.
+ .. deprecated:: 3.11
+
.. function:: path(package, resource)
@@ -1034,6 +1044,8 @@ The following functions are available.
within *package*; it may not contain path separators and it may not have
sub-resources (i.e. it cannot be a directory).
+ .. deprecated:: 3.11
+
.. function:: is_resource(package, name)
@@ -1042,6 +1054,8 @@ The following functions are available.
*package* is either a name or a module object which conforms to the
``Package`` requirements.
+ .. deprecated:: 3.11
+
.. function:: contents(package)
@@ -1052,6 +1066,8 @@ The following functions are available.
*package* is either a name or a module object which conforms to the
``Package`` requirements.
+ .. deprecated:: 3.11
+
:mod:`importlib.machinery` -- Importers and path hooks
------------------------------------------------------
diff --git a/Lib/importlib/_itertools.py b/Lib/importlib/_itertools.py
index dd45f2f096630..cce05582ffc6f 100644
--- a/Lib/importlib/_itertools.py
+++ b/Lib/importlib/_itertools.py
@@ -1,11 +1,27 @@
from itertools import filterfalse
+from typing import (
+ Callable,
+ Iterable,
+ Iterator,
+ Optional,
+ Set,
+ TypeVar,
+ Union,
+)
-def unique_everseen(iterable, key=None):
+# Type and type variable definitions
+_T = TypeVar('_T')
+_U = TypeVar('_U')
+
+
+def unique_everseen(
+ iterable: Iterable[_T], key: Optional[Callable[[_T], _U]] = None
+) -> Iterator[_T]:
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
- seen = set()
+ seen: Set[Union[_T, _U]] = set()
seen_add = seen.add
if key is None:
for element in filterfalse(seen.__contains__, iterable):
diff --git a/Lib/importlib/_legacy.py b/Lib/importlib/_legacy.py
index 2ddec5f90a323..477f89e4c3abd 100644
--- a/Lib/importlib/_legacy.py
+++ b/Lib/importlib/_legacy.py
@@ -1,6 +1,8 @@
+import functools
import os
import pathlib
import types
+import warnings
from typing import Union, Iterable, ContextManager, BinaryIO, TextIO
@@ -10,16 +12,34 @@
Resource = Union[str, os.PathLike]
+def deprecated(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kwargs):
+ warnings.warn(
+ f"{func.__name__} is deprecated. Use files() instead. "
+ "Refer to https://importlib-resources.readthedocs.io"
+ "/en/latest/using.html#migrating-from-legacy for migration advice.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return func(*args, **kwargs)
+
+ return wrapper
+
+
+@deprecated
def open_binary(package: Package, resource: Resource) -> BinaryIO:
"""Return a file-like object opened for binary reading of the resource."""
return (_common.files(package) / _common.normalize_path(resource)).open('rb')
+@deprecated
def read_binary(package: Package, resource: Resource) -> bytes:
"""Return the binary contents of the resource."""
return (_common.files(package) / _common.normalize_path(resource)).read_bytes()
+@deprecated
def open_text(
package: Package,
resource: Resource,
@@ -32,6 +52,7 @@ def open_text(
)
+@deprecated
def read_text(
package: Package,
resource: Resource,
@@ -47,6 +68,7 @@ def read_text(
return fp.read()
+@deprecated
def contents(package: Package) -> Iterable[str]:
"""Return an iterable of entries in `package`.
@@ -57,6 +79,7 @@ def contents(package: Package) -> Iterable[str]:
return [path.name for path in _common.files(package).iterdir()]
+@deprecated
def is_resource(package: Package, name: str) -> bool:
"""True if `name` is a resource inside `package`.
@@ -69,6 +92,7 @@ def is_resource(package: Package, name: str) -> bool:
)
+@deprecated
def path(
package: Package,
resource: Resource,
diff --git a/Lib/test/test_importlib/resources/util.py b/Lib/test/test_importlib/resources/util.py
index d7a049bf8044c..719263223032a 100644
--- a/Lib/test/test_importlib/resources/util.py
+++ b/Lib/test/test_importlib/resources/util.py
@@ -1,8 +1,10 @@
import abc
+import contextlib
import importlib
import io
import sys
import types
+import warnings
from pathlib import Path, PurePath
from .. import data01
@@ -67,6 +69,13 @@ def create_package(file=None, path=None, is_package=True, contents=()):
)
+(a)contextlib.contextmanager
+def suppress_known_deprecation():
+ with warnings.catch_warnings(record=True) as ctx:
+ warnings.simplefilter('default', category=DeprecationWarning)
+ yield ctx
+
+
class CommonTests(metaclass=abc.ABCMeta):
"""
Tests shared by test_open, test_path, and test_read.
diff --git a/Lib/test/test_importlib/test_contents.py b/Lib/test/test_importlib/test_contents.py
index 0f3aa84f5b512..575dcd2f30473 100644
--- a/Lib/test/test_importlib/test_contents.py
+++ b/Lib/test/test_importlib/test_contents.py
@@ -15,7 +15,8 @@ class ContentsTests:
}
def test_contents(self):
- assert self.expected <= set(resources.contents(self.data))
+ with util.suppress_known_deprecation():
+ assert self.expected <= set(resources.contents(self.data))
class ContentsDiskTests(ContentsTests, unittest.TestCase):
diff --git a/Lib/test/test_importlib/test_open.py b/Lib/test/test_importlib/test_open.py
index 6f88ff78b73a0..a9c4a7085c197 100644
--- a/Lib/test/test_importlib/test_open.py
+++ b/Lib/test/test_importlib/test_open.py
@@ -7,38 +7,47 @@
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.open_binary(package, path):
- pass
+ with util.suppress_known_deprecation():
+ with resources.open_binary(package, path):
+ pass
class CommonTextTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.open_text(package, path):
- pass
+ with util.suppress_known_deprecation():
+ with resources.open_text(package, path):
+ pass
class OpenTests:
def test_open_binary(self):
- with resources.open_binary(self.data, 'binary.file') as fp:
- result = fp.read()
- self.assertEqual(result, b'\x00\x01\x02\x03')
+ with util.suppress_known_deprecation():
+ with resources.open_binary(self.data, 'binary.file') as fp:
+ result = fp.read()
+ self.assertEqual(result, b'\x00\x01\x02\x03')
def test_open_text_default_encoding(self):
- with resources.open_text(self.data, 'utf-8.file') as fp:
- result = fp.read()
+ with util.suppress_known_deprecation():
+ with resources.open_text(self.data, 'utf-8.file') as fp:
+ result = fp.read()
self.assertEqual(result, 'Hello, UTF-8 world!\n')
def test_open_text_given_encoding(self):
- with resources.open_text(self.data, 'utf-16.file', 'utf-16', 'strict') as fp:
- result = fp.read()
+ with util.suppress_known_deprecation():
+ with resources.open_text(
+ self.data, 'utf-16.file', 'utf-16', 'strict'
+ ) as fp:
+ result = fp.read()
self.assertEqual(result, 'Hello, UTF-16 world!\n')
def test_open_text_with_errors(self):
# Raises UnicodeError without the 'errors' argument.
- with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'strict') as fp:
- self.assertRaises(UnicodeError, fp.read)
- with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'ignore') as fp:
- result = fp.read()
+ with util.suppress_known_deprecation():
+ with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'strict') as fp:
+ self.assertRaises(UnicodeError, fp.read)
+ with util.suppress_known_deprecation():
+ with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'ignore') as fp:
+ result = fp.read()
self.assertEqual(
result,
'H\x00e\x00l\x00l\x00o\x00,\x00 '
@@ -47,14 +56,16 @@ def test_open_text_with_errors(self):
)
def test_open_binary_FileNotFoundError(self):
- self.assertRaises(
- FileNotFoundError, resources.open_binary, self.data, 'does-not-exist'
- )
+ with util.suppress_known_deprecation():
+ self.assertRaises(
+ FileNotFoundError, resources.open_binary, self.data, 'does-not-exist'
+ )
def test_open_text_FileNotFoundError(self):
- self.assertRaises(
- FileNotFoundError, resources.open_text, self.data, 'does-not-exist'
- )
+ with util.suppress_known_deprecation():
+ self.assertRaises(
+ FileNotFoundError, resources.open_text, self.data, 'does-not-exist'
+ )
class OpenDiskTests(OpenTests, unittest.TestCase):
diff --git a/Lib/test/test_importlib/test_path.py b/Lib/test/test_importlib/test_path.py
index 4436d7f34ef41..3ccbc6fbd2af3 100644
--- a/Lib/test/test_importlib/test_path.py
+++ b/Lib/test/test_importlib/test_path.py
@@ -8,8 +8,9 @@
class CommonTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.path(package, path):
- pass
+ with util.suppress_known_deprecation():
+ with resources.path(package, path):
+ pass
class PathTests:
@@ -17,12 +18,13 @@ def test_reading(self):
# Path should be readable.
# Test also implicitly verifies the returned object is a pathlib.Path
# instance.
- with resources.path(self.data, 'utf-8.file') as path:
- self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
- # pathlib.Path.read_text() was introduced in Python 3.5.
- with path.open('r', encoding='utf-8') as file:
- text = file.read()
- self.assertEqual('Hello, UTF-8 world!\n', text)
+ with util.suppress_known_deprecation():
+ with resources.path(self.data, 'utf-8.file') as path:
+ self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
+ # pathlib.Path.read_text() was introduced in Python 3.5.
+ with path.open('r', encoding='utf-8') as file:
+ text = file.read()
+ self.assertEqual('Hello, UTF-8 world!\n', text)
class PathDiskTests(PathTests, unittest.TestCase):
@@ -32,8 +34,9 @@ def test_natural_path(self):
# Guarantee the internal implementation detail that
# file-system-backed resources do not get the tempdir
# treatment.
- with resources.path(self.data, 'utf-8.file') as path:
- assert 'data' in str(path)
+ with util.suppress_known_deprecation():
+ with resources.path(self.data, 'utf-8.file') as path:
+ assert 'data' in str(path)
class PathMemoryTests(PathTests, unittest.TestCase):
@@ -51,8 +54,9 @@ class PathZipTests(PathTests, util.ZipSetup, unittest.TestCase):
def test_remove_in_context_manager(self):
# It is not an error if the file that was temporarily stashed on the
# file system is removed inside the `with` stanza.
- with resources.path(self.data, 'utf-8.file') as path:
- path.unlink()
+ with util.suppress_known_deprecation():
+ with resources.path(self.data, 'utf-8.file') as path:
+ path.unlink()
if __name__ == '__main__':
diff --git a/Lib/test/test_importlib/test_read.py b/Lib/test/test_importlib/test_read.py
index 357980132b6ec..1bab5c97f41bf 100644
--- a/Lib/test/test_importlib/test_read.py
+++ b/Lib/test/test_importlib/test_read.py
@@ -7,31 +7,40 @@
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- resources.read_binary(package, path)
+ with util.suppress_known_deprecation():
+ resources.read_binary(package, path)
class CommonTextTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- resources.read_text(package, path)
+ with util.suppress_known_deprecation():
+ resources.read_text(package, path)
class ReadTests:
def test_read_binary(self):
- result = resources.read_binary(self.data, 'binary.file')
+ with util.suppress_known_deprecation():
+ result = resources.read_binary(self.data, 'binary.file')
self.assertEqual(result, b'\0\1\2\3')
def test_read_text_default_encoding(self):
- result = resources.read_text(self.data, 'utf-8.file')
+ with util.suppress_known_deprecation():
+ result = resources.read_text(self.data, 'utf-8.file')
self.assertEqual(result, 'Hello, UTF-8 world!\n')
def test_read_text_given_encoding(self):
- result = resources.read_text(self.data, 'utf-16.file', encoding='utf-16')
+ with util.suppress_known_deprecation():
+ result = resources.read_text(self.data, 'utf-16.file', encoding='utf-16')
self.assertEqual(result, 'Hello, UTF-16 world!\n')
def test_read_text_with_errors(self):
# Raises UnicodeError without the 'errors' argument.
- self.assertRaises(UnicodeError, resources.read_text, self.data, 'utf-16.file')
- result = resources.read_text(self.data, 'utf-16.file', errors='ignore')
+ with util.suppress_known_deprecation():
+ self.assertRaises(
+ UnicodeError, resources.read_text, self.data, 'utf-16.file'
+ )
+ with util.suppress_known_deprecation():
+ result = resources.read_text(self.data, 'utf-16.file', errors='ignore')
self.assertEqual(
result,
'H\x00e\x00l\x00l\x00o\x00,\x00 '
@@ -47,11 +56,13 @@ class ReadDiskTests(ReadTests, unittest.TestCase):
class ReadZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
def test_read_submodule_resource(self):
submodule = import_module('ziptestdata.subdirectory')
- result = resources.read_binary(submodule, 'binary.file')
+ with util.suppress_known_deprecation():
+ result = resources.read_binary(submodule, 'binary.file')
self.assertEqual(result, b'\0\1\2\3')
def test_read_submodule_resource_by_name(self):
- result = resources.read_binary('ziptestdata.subdirectory', 'binary.file')
+ with util.suppress_known_deprecation():
+ result = resources.read_binary('ziptestdata.subdirectory', 'binary.file')
self.assertEqual(result, b'\0\1\2\3')
diff --git a/Lib/test/test_importlib/test_resource.py b/Lib/test/test_importlib/test_resource.py
index 612bada5e0316..39904591a5248 100644
--- a/Lib/test/test_importlib/test_resource.py
+++ b/Lib/test/test_importlib/test_resource.py
@@ -15,17 +15,21 @@ class ResourceTests:
# Subclasses are expected to set the `data` attribute.
def test_is_resource_good_path(self):
- self.assertTrue(resources.is_resource(self.data, 'binary.file'))
+ with util.suppress_known_deprecation():
+ self.assertTrue(resources.is_resource(self.data, 'binary.file'))
def test_is_resource_missing(self):
- self.assertFalse(resources.is_resource(self.data, 'not-a-file'))
+ with util.suppress_known_deprecation():
+ self.assertFalse(resources.is_resource(self.data, 'not-a-file'))
def test_is_resource_subresource_directory(self):
# Directories are not resources.
- self.assertFalse(resources.is_resource(self.data, 'subdirectory'))
+ with util.suppress_known_deprecation():
+ self.assertFalse(resources.is_resource(self.data, 'subdirectory'))
def test_contents(self):
- contents = set(resources.contents(self.data))
+ with util.suppress_known_deprecation():
+ contents = set(resources.contents(self.data))
# There may be cruft in the directory listing of the data directory.
# It could have a __pycache__ directory,
# an artifact of the
@@ -58,25 +62,29 @@ def test_resource_contents(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C']
)
- self.assertEqual(set(resources.contents(package)), {'A', 'B', 'C'})
+ with util.suppress_known_deprecation():
+ self.assertEqual(set(resources.contents(package)), {'A', 'B', 'C'})
def test_resource_is_resource(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E', 'D/F']
)
- self.assertTrue(resources.is_resource(package, 'B'))
+ with util.suppress_known_deprecation():
+ self.assertTrue(resources.is_resource(package, 'B'))
def test_resource_directory_is_not_resource(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E', 'D/F']
)
- self.assertFalse(resources.is_resource(package, 'D'))
+ with util.suppress_known_deprecation():
+ self.assertFalse(resources.is_resource(package, 'D'))
def test_resource_missing_is_not_resource(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E', 'D/F']
)
- self.assertFalse(resources.is_resource(package, 'Z'))
+ with util.suppress_known_deprecation():
+ self.assertFalse(resources.is_resource(package, 'Z'))
class ResourceCornerCaseTests(unittest.TestCase):
@@ -94,7 +102,8 @@ def test_package_has_no_reader_fallback(self):
module.__file__ = '/path/which/shall/not/be/named'
module.__spec__.loader = module.__loader__
module.__spec__.origin = module.__file__
- self.assertFalse(resources.is_resource(module, 'A'))
+ with util.suppress_known_deprecation():
+ self.assertFalse(resources.is_resource(module, 'A'))
class ResourceFromZipsTest01(util.ZipSetupBase, unittest.TestCase):
@@ -102,24 +111,28 @@ class ResourceFromZipsTest01(util.ZipSetupBase, unittest.TestCase):
def test_is_submodule_resource(self):
submodule = import_module('ziptestdata.subdirectory')
- self.assertTrue(resources.is_resource(submodule, 'binary.file'))
+ with util.suppress_known_deprecation():
+ self.assertTrue(resources.is_resource(submodule, 'binary.file'))
def test_read_submodule_resource_by_name(self):
- self.assertTrue(
- resources.is_resource('ziptestdata.subdirectory', 'binary.file')
- )
+ with util.suppress_known_deprecation():
+ self.assertTrue(
+ resources.is_resource('ziptestdata.subdirectory', 'binary.file')
+ )
def test_submodule_contents(self):
submodule = import_module('ziptestdata.subdirectory')
- self.assertEqual(
- set(resources.contents(submodule)), {'__init__.py', 'binary.file'}
- )
+ with util.suppress_known_deprecation():
+ self.assertEqual(
+ set(resources.contents(submodule)), {'__init__.py', 'binary.file'}
+ )
def test_submodule_contents_by_name(self):
- self.assertEqual(
- set(resources.contents('ziptestdata.subdirectory')),
- {'__init__.py', 'binary.file'},
- )
+ with util.suppress_known_deprecation():
+ self.assertEqual(
+ set(resources.contents('ziptestdata.subdirectory')),
+ {'__init__.py', 'binary.file'},
+ )
class ResourceFromZipsTest02(util.ZipSetupBase, unittest.TestCase):
@@ -130,12 +143,16 @@ def test_unrelated_contents(self):
Test thata zip with two unrelated subpackages return
distinct resources. Ref python/importlib_resources#44.
"""
- self.assertEqual(
- set(resources.contents('ziptestdata.one')), {'__init__.py', 'resource1.txt'}
- )
- self.assertEqual(
- set(resources.contents('ziptestdata.two')), {'__init__.py', 'resource2.txt'}
- )
+ with util.suppress_known_deprecation():
+ self.assertEqual(
+ set(resources.contents('ziptestdata.one')),
+ {'__init__.py', 'resource1.txt'},
+ )
+ with util.suppress_known_deprecation():
+ self.assertEqual(
+ set(resources.contents('ziptestdata.two')),
+ {'__init__.py', 'resource2.txt'},
+ )
class DeletingZipsTest(unittest.TestCase):
@@ -176,17 +193,20 @@ def tearDown(self):
pass
def test_contents_does_not_keep_open(self):
- c = resources.contents('ziptestdata')
+ with util.suppress_known_deprecation():
+ c = resources.contents('ziptestdata')
self.zip_path.unlink()
del c
def test_is_resource_does_not_keep_open(self):
- c = resources.is_resource('ziptestdata', 'binary.file')
+ with util.suppress_known_deprecation():
+ c = resources.is_resource('ziptestdata', 'binary.file')
self.zip_path.unlink()
del c
def test_is_resource_failure_does_not_keep_open(self):
- c = resources.is_resource('ziptestdata', 'not-present')
+ with util.suppress_known_deprecation():
+ c = resources.is_resource('ziptestdata', 'not-present')
self.zip_path.unlink()
del c
@@ -199,17 +219,20 @@ def test_path_does_not_keep_open(self):
def test_entered_path_does_not_keep_open(self):
# This is what certifi does on import to make its bundle
# available for the process duration.
- c = resources.path('ziptestdata', 'binary.file').__enter__()
+ with util.suppress_known_deprecation():
+ c = resources.path('ziptestdata', 'binary.file').__enter__()
self.zip_path.unlink()
del c
def test_read_binary_does_not_keep_open(self):
- c = resources.read_binary('ziptestdata', 'binary.file')
+ with util.suppress_known_deprecation():
+ c = resources.read_binary('ziptestdata', 'binary.file')
self.zip_path.unlink()
del c
def test_read_text_does_not_keep_open(self):
- c = resources.read_text('ziptestdata', 'utf-8.file', encoding='utf-8')
+ with util.suppress_known_deprecation():
+ c = resources.read_text('ziptestdata', 'utf-8.file', encoding='utf-8')
self.zip_path.unlink()
del c
@@ -226,15 +249,18 @@ def tearDownClass(cls):
sys.path.remove(cls.site_dir)
def test_is_submodule_resource(self):
- self.assertTrue(
- resources.is_resource(import_module('namespacedata01'), 'binary.file')
- )
+ with util.suppress_known_deprecation():
+ self.assertTrue(
+ resources.is_resource(import_module('namespacedata01'), 'binary.file')
+ )
def test_read_submodule_resource_by_name(self):
- self.assertTrue(resources.is_resource('namespacedata01', 'binary.file'))
+ with util.suppress_known_deprecation():
+ self.assertTrue(resources.is_resource('namespacedata01', 'binary.file'))
def test_submodule_contents(self):
- contents = set(resources.contents(import_module('namespacedata01')))
+ with util.suppress_known_deprecation():
+ contents = set(resources.contents(import_module('namespacedata01')))
try:
contents.remove('__pycache__')
except KeyError:
@@ -242,7 +268,8 @@ def test_submodule_contents(self):
self.assertEqual(contents, {'binary.file', 'utf-8.file', 'utf-16.file'})
def test_submodule_contents_by_name(self):
- contents = set(resources.contents('namespacedata01'))
+ with util.suppress_known_deprecation():
+ contents = set(resources.contents('namespacedata01'))
try:
contents.remove('__pycache__')
except KeyError:
diff --git a/Misc/NEWS.d/next/Library/2021-10-18-14-25-35.bpo-45514.YmlzIl.rst b/Misc/NEWS.d/next/Library/2021-10-18-14-25-35.bpo-45514.YmlzIl.rst
new file mode 100644
index 0000000000000..03f944faa8fd7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-10-18-14-25-35.bpo-45514.YmlzIl.rst
@@ -0,0 +1 @@
+Deprecated legacy functions in :mod:`importlib.resources`.
1
0
https://github.com/python/cpython/commit/324527012fa1078428a6207918640cf860…
commit: 324527012fa1078428a6207918640cf860e28c81
branch: main
author: Erlend Egeberg Aasland <erlend.aasland(a)innova.no>
committer: tiran <christian(a)python.org>
date: 2021-11-24T08:19:17+01:00
summary:
bpo-45847: Port _posixshmem to PY_STDLIB_MOD (GH-29738)
files:
M Modules/Setup.stdlib.in
M configure
M configure.ac
M pyconfig.h.in
M setup.py
diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in
index 9de0096c06783..e999775caf3f7 100644
--- a/Modules/Setup.stdlib.in
+++ b/Modules/Setup.stdlib.in
@@ -122,6 +122,9 @@
@MODULE_SYSLOG_TRUE@syslog syslogmodule.c
@MODULE_TERMIOS_TRUE@termios termios.c
+# multiprocessing
+@MODULE__POSIXSHMEM_TRUE@_posixshmem _multiprocessing/posixshmem.c
+
############################################################################
# Modules with third party dependencies
diff --git a/configure b/configure
index 630102585e87e..70c94a4e24d60 100755
--- a/configure
+++ b/configure
@@ -710,6 +710,8 @@ MODULE_OSSAUDIODEV_FALSE
MODULE_OSSAUDIODEV_TRUE
MODULE_GRP_FALSE
MODULE_GRP_TRUE
+MODULE__POSIXSHMEM_FALSE
+MODULE__POSIXSHMEM_TRUE
MODULE_MMAP_FALSE
MODULE_MMAP_TRUE
MODULE_FCNTL_FALSE
@@ -20030,9 +20032,14 @@ fi
# checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c
# shm_* may only be available if linking against librt
-save_LIBS="$LIBS"
-save_includes_default="$ac_includes_default"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing shm_open" >&5
+POSIXSHMEM_CFLAGS='-I$(srcdir)/Modules/_multiprocessing'
+save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
+save_LIBS=$LIBS
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing shm_open" >&5
$as_echo_n "checking for library containing shm_open... " >&6; }
if ${ac_cv_search_shm_open+:} false; then :
$as_echo_n "(cached) " >&6
@@ -20088,33 +20095,20 @@ if test "$ac_res" != no; then :
fi
-if test "$ac_cv_search_shm_open" = "-lrt"; then
-
-$as_echo "#define SHM_NEEDS_LIBRT 1" >>confdefs.h
-
-fi
-for ac_header in sys/mman.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_mman_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_MMAN_H 1
-_ACEOF
-
+ if test "x$ac_cv_search_shm_open" = x-lrt; then :
+ POSIXSHMEM_LIBS="-lrt"
fi
-done
-
-# temporarily override ac_includes_default for AC_CHECK_FUNCS below
-ac_includes_default="\
-${ac_includes_default}
-#ifndef __cplusplus
-# ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-# endif
-#endif
-"
-for ac_func in shm_open shm_unlink
+ save_ac_includes_default=$ac_includes_default
+ ac_includes_default="\
+ ${ac_includes_default}
+ #ifndef __cplusplus
+ # ifdef HAVE_SYS_MMAN_H
+ # include <sys/mman.h>
+ # endif
+ #endif
+ "
+ for ac_func in shm_open shm_unlink
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -20122,13 +20116,20 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
-
+ have_posix_shmem=yes
+else
+ have_posix_shmem=no
fi
done
-# we don't want to link with librt always, restore LIBS
-LIBS="$save_LIBS"
-ac_includes_default="$save_includes_default"
+ ac_includes_default=$save_ac_includes_default
+
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
+LIBS=$save_LIBS
+
+
# Check for usable OpenSSL
@@ -21072,6 +21073,42 @@ fi
$as_echo "$py_cv_module_mmap" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _posixshmem" >&5
+$as_echo_n "checking for stdlib extension module _posixshmem... " >&6; }
+ case $py_stdlib_not_available in #(
+ *_posixshmem*) :
+ py_cv_module__posixshmem=n/a ;; #(
+ *) :
+ if true; then :
+ if test "$have_posix_shmem" = "yes"; then :
+ py_cv_module__posixshmem=yes
+else
+ py_cv_module__posixshmem=missing
+fi
+else
+ py_cv_module__posixshmem=disabled
+fi
+ ;;
+esac
+ as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM=$py_cv_module__posixshmem$as_nl"
+ if test "x$py_cv_module__posixshmem" = xyes; then :
+
+ as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_CFLAGS=$POSIXSHMEM_CFLAGS$as_nl"
+ as_fn_append MODULE_BLOCK "MODULE__POSIXSHMEM_LDFLAGS=$POSIXSHMEM_LIBS$as_nl"
+
+fi
+ if test "$py_cv_module__posixshmem" = yes; then
+ MODULE__POSIXSHMEM_TRUE=
+ MODULE__POSIXSHMEM_FALSE='#'
+else
+ MODULE__POSIXSHMEM_TRUE='#'
+ MODULE__POSIXSHMEM_FALSE=
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__posixshmem" >&5
+$as_echo "$py_cv_module__posixshmem" >&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; }
@@ -22621,6 +22658,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__POSIXSHMEM_TRUE}" && test -z "${MODULE__POSIXSHMEM_FALSE}"; then
+ as_fn_error $? "conditional \"MODULE__POSIXSHMEM\" 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 34a2c694ddfc2..a161a8cf88545 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5875,27 +5875,24 @@ AS_VAR_IF([ac_cv_func_getrandom], [yes], [
# checks for POSIX shared memory, used by Modules/_multiprocessing/posixshmem.c
# shm_* may only be available if linking against librt
-save_LIBS="$LIBS"
-save_includes_default="$ac_includes_default"
-AC_SEARCH_LIBS(shm_open, rt)
-if test "$ac_cv_search_shm_open" = "-lrt"; then
- AC_DEFINE(SHM_NEEDS_LIBRT, 1,
- [Define to 1 if you must link with -lrt for shm_open().])
-fi
-AC_CHECK_HEADERS(sys/mman.h)
-# temporarily override ac_includes_default for AC_CHECK_FUNCS below
-ac_includes_default="\
-${ac_includes_default}
-#ifndef __cplusplus
-# ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-# endif
-#endif
-"
-AC_CHECK_FUNCS([shm_open shm_unlink])
-# we don't want to link with librt always, restore LIBS
-LIBS="$save_LIBS"
-ac_includes_default="$save_includes_default"
+POSIXSHMEM_CFLAGS='-I$(srcdir)/Modules/_multiprocessing'
+WITH_SAVE_ENV([
+ AC_SEARCH_LIBS([shm_open], [rt])
+ AS_VAR_IF([ac_cv_search_shm_open], [-lrt], [POSIXSHMEM_LIBS="-lrt"])
+
+ dnl Temporarily override ac_includes_default for AC_CHECK_FUNCS below.
+ _SAVE_VAR([ac_includes_default])
+ ac_includes_default="\
+ ${ac_includes_default}
+ #ifndef __cplusplus
+ # ifdef HAVE_SYS_MMAN_H
+ # include <sys/mman.h>
+ # endif
+ #endif
+ "
+ AC_CHECK_FUNCS([shm_open shm_unlink], [have_posix_shmem=yes], [have_posix_shmem=no])
+ _RESTORE_VAR([ac_includes_default])
+])
# Check for usable OpenSSL
AX_CHECK_OPENSSL([have_openssl=yes],[have_openssl=no])
@@ -6251,6 +6248,9 @@ 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([_posixshmem],
+ [], [test "$have_posix_shmem" = "yes"],
+ [$POSIXSHMEM_CFLAGS], [$POSIXSHMEM_LIBS])
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 bb9ae4c3dbc82..67f27c2b17e3b 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -1469,9 +1469,6 @@
/* Define if setpgrp() must be called as setpgrp(0, 0). */
#undef SETPGRP_HAVE_ARG
-/* Define to 1 if you must link with -lrt for shm_open(). */
-#undef SHM_NEEDS_LIBRT
-
/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */
#undef SIGNED_RIGHT_SHIFT_ZERO_FILLS
diff --git a/setup.py b/setup.py
index 98a20150c1e0b..72497de5c0d3a 100644
--- a/setup.py
+++ b/setup.py
@@ -1397,20 +1397,7 @@ def detect_multiprocessing(self):
self.add(Extension('_multiprocessing', multiprocessing_srcs,
include_dirs=["Modules/_multiprocessing"]))
- if (not MS_WINDOWS and
- sysconfig.get_config_var('HAVE_SHM_OPEN') and
- sysconfig.get_config_var('HAVE_SHM_UNLINK')):
- posixshmem_srcs = ['_multiprocessing/posixshmem.c']
- libs = []
- if sysconfig.get_config_var('SHM_NEEDS_LIBRT'):
- # need to link with librt to get shm_open()
- libs.append('rt')
- self.add(Extension('_posixshmem', posixshmem_srcs,
- define_macros={},
- libraries=libs,
- include_dirs=["Modules/_multiprocessing"]))
- else:
- self.missing.append('_posixshmem')
+ self.addext(Extension('_posixshmem', ['_multiprocessing/posixshmem.c']))
def detect_uuid(self):
# Build the _uuid module if possible
1
0
24 Nov '21
https://github.com/python/cpython/commit/dd8ce9ea8d7e45224a348ea7962b5f50cb…
commit: dd8ce9ea8d7e45224a348ea7962b5f50cbf86dc5
branch: main
author: Christian Heimes <christian(a)python.org>
committer: tiran <christian(a)python.org>
date: 2021-11-24T08:07:15+01:00
summary:
bpo-45886: Allow overriding freeze command for cross compiling (GH-29735)
files:
A Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
M Makefile.pre.in
M Tools/scripts/freeze_modules.py
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 476a64cb7a500..bb624755dd3ee 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1008,6 +1008,9 @@ Python/deepfreeze/frozen_only.c: Python/frozen_modules/frozen_only.h $(DEEPFREEZ
############################################################################
# frozen modules (including importlib)
+# Allow developers to override freeze_module command for cross building (bpo-45886)
+FREEZE_MODULE?=Programs/_freeze_module
+
# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
FROZEN_FILES_IN = \
Lib/importlib/_bootstrap.py \
@@ -1061,69 +1064,69 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN)
# BEGIN: freezing modules
-Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py
- Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
+Python/frozen_modules/importlib._bootstrap.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap.py
+ $(FREEZE_MODULE) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
-Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py
- Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
+Python/frozen_modules/importlib._bootstrap_external.h: $(FREEZE_MODULE) Lib/importlib/_bootstrap_external.py
+ $(FREEZE_MODULE) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
-Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py
- Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
+Python/frozen_modules/zipimport.h: $(FREEZE_MODULE) Lib/zipimport.py
+ $(FREEZE_MODULE) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
-Python/frozen_modules/abc.h: Programs/_freeze_module Lib/abc.py
- Programs/_freeze_module abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
+Python/frozen_modules/abc.h: $(FREEZE_MODULE) Lib/abc.py
+ $(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
-Python/frozen_modules/codecs.h: Programs/_freeze_module Lib/codecs.py
- Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
+Python/frozen_modules/codecs.h: $(FREEZE_MODULE) Lib/codecs.py
+ $(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
-Python/frozen_modules/io.h: Programs/_freeze_module Lib/io.py
- Programs/_freeze_module io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
+Python/frozen_modules/io.h: $(FREEZE_MODULE) Lib/io.py
+ $(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
-Python/frozen_modules/_collections_abc.h: Programs/_freeze_module Lib/_collections_abc.py
- Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
+Python/frozen_modules/_collections_abc.h: $(FREEZE_MODULE) Lib/_collections_abc.py
+ $(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
-Python/frozen_modules/_sitebuiltins.h: Programs/_freeze_module Lib/_sitebuiltins.py
- Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
+Python/frozen_modules/_sitebuiltins.h: $(FREEZE_MODULE) Lib/_sitebuiltins.py
+ $(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
-Python/frozen_modules/genericpath.h: Programs/_freeze_module Lib/genericpath.py
- Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
+Python/frozen_modules/genericpath.h: $(FREEZE_MODULE) Lib/genericpath.py
+ $(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
-Python/frozen_modules/ntpath.h: Programs/_freeze_module Lib/ntpath.py
- Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
+Python/frozen_modules/ntpath.h: $(FREEZE_MODULE) Lib/ntpath.py
+ $(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
-Python/frozen_modules/posixpath.h: Programs/_freeze_module Lib/posixpath.py
- Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
+Python/frozen_modules/posixpath.h: $(FREEZE_MODULE) Lib/posixpath.py
+ $(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
-Python/frozen_modules/os.h: Programs/_freeze_module Lib/os.py
- Programs/_freeze_module os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
+Python/frozen_modules/os.h: $(FREEZE_MODULE) Lib/os.py
+ $(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
-Python/frozen_modules/site.h: Programs/_freeze_module Lib/site.py
- Programs/_freeze_module site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
+Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py
+ $(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
-Python/frozen_modules/stat.h: Programs/_freeze_module Lib/stat.py
- Programs/_freeze_module stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
+Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py
+ $(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
-Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py
- Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
+Python/frozen_modules/__hello__.h: $(FREEZE_MODULE) Lib/__hello__.py
+ $(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
-Python/frozen_modules/__phello__.h: Programs/_freeze_module Lib/__phello__/__init__.py
- Programs/_freeze_module __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
+Python/frozen_modules/__phello__.h: $(FREEZE_MODULE) Lib/__phello__/__init__.py
+ $(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
-Python/frozen_modules/__phello__.ham.h: Programs/_freeze_module Lib/__phello__/ham/__init__.py
- Programs/_freeze_module __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
+Python/frozen_modules/__phello__.ham.h: $(FREEZE_MODULE) Lib/__phello__/ham/__init__.py
+ $(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
-Python/frozen_modules/__phello__.ham.eggs.h: Programs/_freeze_module Lib/__phello__/ham/eggs.py
- Programs/_freeze_module __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
+Python/frozen_modules/__phello__.ham.eggs.h: $(FREEZE_MODULE) Lib/__phello__/ham/eggs.py
+ $(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
-Python/frozen_modules/__phello__.spam.h: Programs/_freeze_module Lib/__phello__/spam.py
- Programs/_freeze_module __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
+Python/frozen_modules/__phello__.spam.h: $(FREEZE_MODULE) Lib/__phello__/spam.py
+ $(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
-Python/frozen_modules/frozen_only.h: Programs/_freeze_module Tools/freeze/flag.py
- Programs/_freeze_module frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
+Python/frozen_modules/frozen_only.h: $(FREEZE_MODULE) Tools/freeze/flag.py
+ $(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
# END: freezing modules
-Tools/scripts/freeze_modules.py: Programs/_freeze_module
+Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)
.PHONY: regen-frozen
regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
diff --git a/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst b/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
new file mode 100644
index 0000000000000..b08b9c8a5441e
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-11-23-23-37-49.bpo-45886._Ulnh-.rst
@@ -0,0 +1,2 @@
+The ``_freeze_module`` program path can now be overridden on the command
+line, e.g. ``make FREEZE_MODULE=../x86_64/Program/_freeze_module``.
diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py
index 4281b67e27cb3..a36f74ced4187 100644
--- a/Tools/scripts/freeze_modules.py
+++ b/Tools/scripts/freeze_modules.py
@@ -598,10 +598,10 @@ def regen_makefile(modules):
pyfile = relpath_for_posix_display(src.pyfile, ROOT_DIR)
pyfiles.append(f'\t\t{pyfile} \\')
- freeze = (f'Programs/_freeze_module {src.frozenid} '
+ freeze = (f'$(FREEZE_MODULE) {src.frozenid} '
f'$(srcdir)/{pyfile} {header}')
rules.extend([
- f'{header}: Programs/_freeze_module {pyfile}',
+ f'{header}: $(FREEZE_MODULE) {pyfile}',
f'\t{freeze}',
'',
])
1
0
23 Nov '21
https://github.com/python/cpython/commit/ae065f83625f3abcf75d928f405e05582f…
commit: ae065f83625f3abcf75d928f405e05582fc035b4
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: miss-islington <31488909+miss-islington(a)users.noreply.github.com>
date: 2021-11-23T21:02:32-08:00
summary:
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
(cherry picked from commit f9de97aae5fe9dafb58a8099171f4a09c449f4e8)
Co-authored-by: Zachary Ware <zach(a)python.org>
files:
A Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
M PC/launcher.c
diff --git a/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
new file mode 100644
index 0000000000000..000f2fd3cc989
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
@@ -0,0 +1,4 @@
+Fix Python Launcher's ability to distinguish between versions 3.1 and 3.10
+when either one is explicitly requested. Previously, 3.1 would be used if
+3.10 was requested but not installed, and 3.10 would be used if 3.1 was
+requested but 3.10 was installed.
diff --git a/PC/launcher.c b/PC/launcher.c
index f5b225ac08cfe..84c8a1d14ea41 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -542,8 +542,17 @@ find_python_by_version(wchar_t const * wanted_ver)
}
for (i = 0; i < num_installed_pythons; i++, ip++) {
n = wcslen(ip->version);
- if (n > wlen)
+ /*
+ * If wlen is greater than 1, we're probably trying to find a specific
+ * version and thus want an exact match: 3.1 != 3.10. Otherwise, we
+ * just want a prefix match.
+ */
+ if ((wlen > 1) && (n != wlen)) {
+ continue;
+ }
+ if (n > wlen) {
n = wlen;
+ }
if ((wcsncmp(ip->version, wanted_ver, n) == 0) &&
/* bits == 0 => don't care */
((bits == 0) || (ip->bits == bits))) {
1
0
https://github.com/python/cpython/commit/f9de97aae5fe9dafb58a8099171f4a09c4…
commit: f9de97aae5fe9dafb58a8099171f4a09c449f4e8
branch: main
author: Zachary Ware <zach(a)python.org>
committer: zware <zachary.ware(a)gmail.com>
date: 2021-11-23T22:41:04-06:00
summary:
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
files:
A Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
M PC/launcher.c
diff --git a/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
new file mode 100644
index 0000000000000..000f2fd3cc989
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
@@ -0,0 +1,4 @@
+Fix Python Launcher's ability to distinguish between versions 3.1 and 3.10
+when either one is explicitly requested. Previously, 3.1 would be used if
+3.10 was requested but not installed, and 3.10 would be used if 3.1 was
+requested but 3.10 was installed.
diff --git a/PC/launcher.c b/PC/launcher.c
index fbfb49ae857ac..f8b8a3db39775 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -542,8 +542,17 @@ find_python_by_version(wchar_t const * wanted_ver)
}
for (i = 0; i < num_installed_pythons; i++, ip++) {
n = wcslen(ip->version);
- if (n > wlen)
+ /*
+ * If wlen is greater than 1, we're probably trying to find a specific
+ * version and thus want an exact match: 3.1 != 3.10. Otherwise, we
+ * just want a prefix match.
+ */
+ if ((wlen > 1) && (n != wlen)) {
+ continue;
+ }
+ if (n > wlen) {
n = wlen;
+ }
if ((wcsncmp(ip->version, wanted_ver, n) == 0) &&
/* bits == 0 => don't care */
((bits == 0) || (ip->bits == bits))) {
1
0
https://github.com/python/cpython/commit/9cf5646bb465b7d3d68bfe6d4711feb43d…
commit: 9cf5646bb465b7d3d68bfe6d4711feb43d565051
branch: main
author: Christian Heimes <christian(a)python.org>
committer: tiran <christian(a)python.org>
date: 2021-11-23T22:58:38+01:00
summary:
bpo-45847: Port _gdbm to PY_STDLIB_MOD (GH-29720)
files:
M Modules/Setup.stdlib.in
M configure
M configure.ac
M pyconfig.h.in
M setup.py
diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in
index 9f66d531fef0f..9de0096c06783 100644
--- a/Modules/Setup.stdlib.in
+++ b/Modules/Setup.stdlib.in
@@ -66,6 +66,11 @@
@MODULE__LZMA_TRUE@_lzma _lzmamodule.c
@MODULE_ZLIB_TRUE@zlib zlibmodule.c
+# dbm/gdbm
+# dbm needs either libndbm, libgdbm_compat, or libdb 5.x
+# gdbm module needs -lgdbm
+@MODULE__GDBM_TRUE@_gdbm _gdbmmodule.c
+
# hashing builtins, can be disabled with --without-builtin-hashlib-hashes
@MODULE__MD5_TRUE@_md5 md5module.c
@MODULE__SHA1_TRUE@_sha1 sha1module.c
diff --git a/configure b/configure
index ac0a1f320b2a7..630102585e87e 100755
--- a/configure
+++ b/configure
@@ -658,6 +658,8 @@ MODULE__SQLITE3_FALSE
MODULE__SQLITE3_TRUE
MODULE_NIS_FALSE
MODULE_NIS_TRUE
+MODULE__GDBM_FALSE
+MODULE__GDBM_TRUE
MODULE__DECIMAL_FALSE
MODULE__DECIMAL_TRUE
MODULE__CRYPT_FALSE
@@ -807,6 +809,8 @@ DTRACE_OBJS
DTRACE_HEADERS
DFLAGS
DTRACE
+GDBM_LIBS
+GDBM_CFLAGS
TCLTK_LIBS
TCLTK_INCLUDES
LIBSQLITE3_LIBS
@@ -1044,6 +1048,8 @@ LIBNSL_CFLAGS
LIBNSL_LIBS
LIBSQLITE3_CFLAGS
LIBSQLITE3_LIBS
+GDBM_CFLAGS
+GDBM_LIBS
ZLIB_CFLAGS
ZLIB_LIBS
BZIP2_CFLAGS
@@ -1832,6 +1838,8 @@ Some influential environment variables:
C compiler flags for LIBSQLITE3, overriding pkg-config
LIBSQLITE3_LIBS
linker flags for LIBSQLITE3, overriding pkg-config
+ GDBM_CFLAGS C compiler flags for gdbm
+ GDBM_LIBS additional linker flags for gdbm
ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
ZLIB_LIBS linker flags for ZLIB, overriding pkg-config
BZIP2_CFLAGS
@@ -11668,8 +11676,17 @@ else
TCLTK_LIBS="$with_tcltk_libs"
fi
-# check for _gdbmmodulec dependencies
-for ac_header in gdbm.h
+
+
+save_CFLAGS=$CFLAGS
+save_CPPFLAGS=$CPPFLAGS
+save_LDFLAGS=$LDFLAGS
+save_LIBS=$LIBS
+
+
+ CPPFLAGS="$GDBM_CFLAGS $CFLAGS"
+ LDFLAGS="$GDBM_LIBS $LDFLAGS"
+ for ac_header in gdbm.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "gdbm.h" "ac_cv_header_gdbm_h" "$ac_includes_default"
if test "x$ac_cv_header_gdbm_h" = xyes; then :
@@ -11677,8 +11694,7 @@ if test "x$ac_cv_header_gdbm_h" = xyes; then :
#define HAVE_GDBM_H 1
_ACEOF
- LIBS_SAVE=$LIBS
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdbm_open in -lgdbm" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdbm_open in -lgdbm" >&5
$as_echo_n "checking for gdbm_open in -lgdbm... " >&6; }
if ${ac_cv_lib_gdbm_gdbm_open+:} false; then :
$as_echo_n "(cached) " >&6
@@ -11715,21 +11731,29 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_gdbm_open" >&5
$as_echo "$ac_cv_lib_gdbm_gdbm_open" >&6; }
if test "x$ac_cv_lib_gdbm_gdbm_open" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGDBM 1
-_ACEOF
- LIBS="-lgdbm $LIBS"
+ have_gdbm=yes
+ GDBM_LIBS="$GDBM_LIBS -lgdbm"
+else
+ have_gdbm=no
fi
- LIBS=$LIBS_SAVE
+else
+ have_gdbm=no
fi
done
+CFLAGS=$save_CFLAGS
+CPPFLAGS=$save_CPPFLAGS
+LDFLAGS=$save_LDFLAGS
+LIBS=$save_LIBS
+
+
+
# check for _dbmmodule.c dependencies
for ac_header in ndbm.h
do :
@@ -12009,22 +12033,33 @@ $as_echo_n "checking for --with-dbmliborder... " >&6; }
# Check whether --with-dbmliborder was given.
if test "${with_dbmliborder+set}" = set; then :
withval=$with_dbmliborder;
-if test x$with_dbmliborder = xyes
-then
-as_fn_error $? "proper usage is --with-dbmliborder=db1:db2:..." "$LINENO" 5
else
- as_save_IFS=$IFS
- IFS=:
- for db in $with_dbmliborder; do
- if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
- then
- as_fn_error $? "proper usage is --with-dbmliborder=db1:db2:..." "$LINENO" 5
- fi
- done
- IFS=$as_save_IFS
-fi
+ with_dbmliborder=ndbm:gdbm:bdb
fi
+
+have_gdbm_dbmliborder=no
+as_save_IFS=$IFS
+IFS=:
+for db in $with_dbmliborder; do
+ case $db in #(
+ ndbm) :
+ ;; #(
+ gdbm) :
+ have_gdbm_dbmliborder=yes ;; #(
+ bdb) :
+ ;; #(
+ *) :
+ with_dbmliborder=error
+ ;;
+esac
+done
+IFS=$as_save_IFS
+if test "x$with_dbmliborder" = xerror; then :
+
+ as_fn_error $? "proper usage is --with-dbmliborder=db1:db2:... (ndbm:gdbm:bdb)" "$LINENO" 5
+
+fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_dbmliborder" >&5
$as_echo "$with_dbmliborder" >&6; }
@@ -21725,6 +21760,42 @@ fi
$as_echo "$py_cv_module__decimal" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _gdbm" >&5
+$as_echo_n "checking for stdlib extension module _gdbm... " >&6; }
+ case $py_stdlib_not_available in #(
+ *_gdbm*) :
+ py_cv_module__gdbm=n/a ;; #(
+ *) :
+ if test "$have_gdbm_dbmliborder" = yes; then :
+ if test "$have_gdbm" = yes; then :
+ py_cv_module__gdbm=yes
+else
+ py_cv_module__gdbm=missing
+fi
+else
+ py_cv_module__gdbm=disabled
+fi
+ ;;
+esac
+ as_fn_append MODULE_BLOCK "MODULE__GDBM=$py_cv_module__gdbm$as_nl"
+ if test "x$py_cv_module__gdbm" = xyes; then :
+
+ as_fn_append MODULE_BLOCK "MODULE__GDBM_CFLAGS=$GDBM_CFLAGS$as_nl"
+ as_fn_append MODULE_BLOCK "MODULE__GDBM_LDFLAGS=$GDBM_LIBS$as_nl"
+
+fi
+ if test "$py_cv_module__gdbm" = yes; then
+ MODULE__GDBM_TRUE=
+ MODULE__GDBM_FALSE='#'
+else
+ MODULE__GDBM_TRUE='#'
+ MODULE__GDBM_FALSE=
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__gdbm" >&5
+$as_echo "$py_cv_module__gdbm" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module nis" >&5
$as_echo_n "checking for stdlib extension module nis... " >&6; }
case $py_stdlib_not_available in #(
@@ -22650,6 +22721,10 @@ if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then
as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${MODULE__GDBM_TRUE}" && test -z "${MODULE__GDBM_FALSE}"; then
+ as_fn_error $? "conditional \"MODULE__GDBM\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${MODULE_NIS_TRUE}" && test -z "${MODULE_NIS_FALSE}"; then
as_fn_error $? "conditional \"MODULE_NIS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index 92afdf39fefc0..34a2c694ddfc2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3303,11 +3303,19 @@ else
TCLTK_LIBS="$with_tcltk_libs"
fi
-# check for _gdbmmodulec dependencies
-AC_CHECK_HEADERS([gdbm.h], [
- LIBS_SAVE=$LIBS
- AC_CHECK_LIB([gdbm], [gdbm_open])
- LIBS=$LIBS_SAVE
+dnl check for _gdbmmodule dependencies
+dnl NOTE: gdbm does not provide a pkgconf file.
+AC_ARG_VAR([GDBM_CFLAGS], [C compiler flags for gdbm])
+AC_ARG_VAR([GDBM_LIBS], [additional linker flags for gdbm])
+WITH_SAVE_ENV([
+ CPPFLAGS="$GDBM_CFLAGS $CFLAGS"
+ LDFLAGS="$GDBM_LIBS $LDFLAGS"
+ AC_CHECK_HEADERS([gdbm.h], [
+ AC_CHECK_LIB([gdbm], [gdbm_open], [
+ have_gdbm=yes
+ GDBM_LIBS="$GDBM_LIBS -lgdbm"
+ ], [have_gdbm=no])
+ ], [have_gdbm=no])
])
# check for _dbmmodule.c dependencies
@@ -3375,21 +3383,23 @@ AC_CHECK_HEADERS([db.h], [
AC_MSG_CHECKING(for --with-dbmliborder)
AC_ARG_WITH(dbmliborder,
AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
-[
-if test x$with_dbmliborder = xyes
-then
-AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
-else
- as_save_IFS=$IFS
- IFS=:
- for db in $with_dbmliborder; do
- if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
- then
- AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
- fi
- done
- IFS=$as_save_IFS
-fi])
+[], [with_dbmliborder=ndbm:gdbm:bdb])
+
+have_gdbm_dbmliborder=no
+as_save_IFS=$IFS
+IFS=:
+for db in $with_dbmliborder; do
+ AS_CASE([$db],
+ [ndbm], [],
+ [gdbm], [have_gdbm_dbmliborder=yes],
+ [bdb], [],
+ [with_dbmliborder=error]
+ )
+done
+IFS=$as_save_IFS
+AS_VAR_IF([with_dbmliborder], [error], [
+ AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (ndbm:gdbm:bdb)])
+])
AC_MSG_RESULT($with_dbmliborder)
# Templates for things AC_DEFINEd more than once.
@@ -6279,6 +6289,9 @@ PY_STDLIB_MOD([_crypt],
[], [test "$ac_cv_crypt_crypt" = yes],
[$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS])
PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS])
+PY_STDLIB_MOD([_gdbm],
+ [test "$have_gdbm_dbmliborder" = yes], [test "$have_gdbm" = yes],
+ [$GDBM_CFLAGS], [$GDBM_LIBS])
PY_STDLIB_MOD([nis],
[], [test "$have_nis" = yes -a "$ac_cv_header_rpc_rpc_h" = yes],
[$LIBNSL_CFLAGS], [$LIBNSL_LIBS])
diff --git a/pyconfig.h.in b/pyconfig.h.in
index c9c58656f58ac..bb9ae4c3dbc82 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -604,9 +604,6 @@
/* Define to 1 if you have the `dld' library (-ldld). */
#undef HAVE_LIBDLD
-/* Define to 1 if you have the `gdbm' library (-lgdbm). */
-#undef HAVE_LIBGDBM
-
/* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). */
#undef HAVE_LIBGDBM_COMPAT
diff --git a/setup.py b/setup.py
index 7972bac46c106..98a20150c1e0b 100644
--- a/setup.py
+++ b/setup.py
@@ -1256,11 +1256,9 @@ def detect_dbm_gdbm(self):
# libdb, gdbm and ndbm headers and libraries
have_ndbm_h = sysconfig.get_config_var("HAVE_NDBM_H")
- have_gdbm_h = sysconfig.get_config_var("HAVE_GDBM_H")
have_gdbm_ndbm_h = sysconfig.get_config_var("HAVE_GDBM_NDBM_H")
have_gdbm_dash_ndbm_h = sysconfig.get_config_var("HAVE_GDBM_DASH_NDBM_H")
have_libndbm = sysconfig.get_config_var("HAVE_LIBNDBM")
- have_libgdbm = sysconfig.get_config_var("HAVE_LIBGDBM")
have_libgdbm_compat = sysconfig.get_config_var("HAVE_LIBGDBM_COMPAT")
have_libdb = sysconfig.get_config_var("HAVE_LIBDB")
@@ -1318,11 +1316,7 @@ def detect_dbm_gdbm(self):
self.missing.append('_dbm')
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
- if 'gdbm' in dbm_order and have_libgdbm:
- self.add(Extension('_gdbm', ['_gdbmmodule.c'],
- libraries=['gdbm']))
- else:
- self.missing.append('_gdbm')
+ self.addext(Extension('_gdbm', ['_gdbmmodule.c']))
def detect_sqlite(self):
sources = [
1
0