summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-24 09:20:37 (GMT)
committerGitHub <noreply@github.com>2021-11-24 09:20:37 (GMT)
commit8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f (patch)
treeb0eea88b3769dabc134777ba981a795eff554ac4
parentd5cd2effa69551c6bc7edfef8a414d545dea9117 (diff)
downloadcpython-8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f.zip
cpython-8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f.tar.gz
cpython-8af6481f6b7d43646c47d8fa6cc6d5eb465e2b0f.tar.bz2
bpo-45847: Port _uuid to PY_STDLIB_MOD (GH-29741)
-rw-r--r--Modules/Setup.stdlib.in2
-rw-r--r--Modules/_uuidmodule.c10
-rwxr-xr-xconfigure371
-rw-r--r--configure.ac67
-rw-r--r--pyconfig.h.in3
-rw-r--r--setup.py12
6 files changed, 391 insertions, 74 deletions
diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in
index e999775..eadd161 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 3f33e22..eae38f5 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 70c94a4..d2d7992 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 a161a8c..4961e5a 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 67f27c2..842759f 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 72497de..932667a 100644
--- a/setup.py
+++ b/setup.py
@@ -1401,17 +1401,7 @@ class PyBuildExt(build_ext):
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