Skip to content

Commit 91a51c5

Browse files
[3.9] bpo-43158: Use configure values for building _uuid extension (GH-29353) (GH-29363)
Co-authored-by: Christian Heimes <[email protected]>
1 parent da04bef commit 91a51c5

File tree

5 files changed

+86
-7
lines changed

5 files changed

+86
-7
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``setup.py`` now uses values from configure script to build the ``_uuid``
2+
extension module. Configure now detects util-linux's ``libuuid``, too.

configure

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9920,6 +9920,75 @@ $as_echo "no" >&6; }
99209920
fi
99219921
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
99229922

9923+
save_LIBS=$LIBS
9924+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uuid_generate_time_safe" >&5
9925+
$as_echo_n "checking for library containing uuid_generate_time_safe... " >&6; }
9926+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
9927+
$as_echo_n "(cached) " >&6
9928+
else
9929+
ac_func_search_save_LIBS=$LIBS
9930+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9931+
/* end confdefs.h. */
9932+
9933+
/* Override any GCC internal prototype to avoid an error.
9934+
Use char because int might match the return type of a GCC
9935+
builtin and then its argument prototype would still apply. */
9936+
#ifdef __cplusplus
9937+
extern "C"
9938+
#endif
9939+
char uuid_generate_time_safe ();
9940+
int
9941+
main ()
9942+
{
9943+
return uuid_generate_time_safe ();
9944+
;
9945+
return 0;
9946+
}
9947+
_ACEOF
9948+
for ac_lib in '' uuid; do
9949+
if test -z "$ac_lib"; then
9950+
ac_res="none required"
9951+
else
9952+
ac_res=-l$ac_lib
9953+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
9954+
fi
9955+
if ac_fn_c_try_link "$LINENO"; then :
9956+
ac_cv_search_uuid_generate_time_safe=$ac_res
9957+
fi
9958+
rm -f core conftest.err conftest.$ac_objext \
9959+
conftest$ac_exeext
9960+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
9961+
break
9962+
fi
9963+
done
9964+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
9965+
9966+
else
9967+
ac_cv_search_uuid_generate_time_safe=no
9968+
fi
9969+
rm conftest.$ac_ext
9970+
LIBS=$ac_func_search_save_LIBS
9971+
fi
9972+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uuid_generate_time_safe" >&5
9973+
$as_echo "$ac_cv_search_uuid_generate_time_safe" >&6; }
9974+
ac_res=$ac_cv_search_uuid_generate_time_safe
9975+
if test "$ac_res" != no; then :
9976+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
9977+
9978+
9979+
$as_echo "#define HAVE_LIBUUID 1" >>confdefs.h
9980+
,
9981+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9982+
$as_echo "yes" >&6; }
9983+
9984+
else
9985+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9986+
$as_echo "no" >&6; }
9987+
9988+
fi
9989+
9990+
LIBS=$save_LIBS
9991+
99239992
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
99249993
# FreeBSD and OpenBSD provides support as well
99259994
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_create" >&5

configure.ac

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2873,8 +2873,13 @@ void *x = uuid_generate_time_safe
28732873
[AC_MSG_RESULT(no)]
28742874
)
28752875

2876+
# check for libuuid from util-linux
2877+
save_LIBS=$LIBS
2878+
AC_CHECK_LIB([uuid], [uuid_generate_time])
2879+
LIBS=$save_LIBS
2880+
28762881
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
2877-
# FreeBSD and OpenBSD provides support as well
2882+
# FreeBSD and OpenBSD provides support in libc as well.
28782883
AC_MSG_CHECKING(for uuid_create)
28792884
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
28802885
#ifndef uuid_create

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@
613613
/* Define to 1 if you have the <libutil.h> header file. */
614614
#undef HAVE_LIBUTIL_H
615615

616+
/* Define you have libuuid. */
617+
#undef HAVE_LIBUUID
618+
616619
/* Define if you have the 'link' function. */
617620
#undef HAVE_LINK
618621

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,15 +1770,15 @@ def detect_multiprocessing(self):
17701770

17711771
def detect_uuid(self):
17721772
# Build the _uuid module if possible
1773-
uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"])
1774-
if uuid_incs is not None:
1775-
if self.compiler.find_library_file(self.lib_dirs, 'uuid'):
1776-
uuid_libs = ['uuid']
1773+
uuid_h = sysconfig.get_config_var("HAVE_UUID_H")
1774+
uuid_uuid_h = sysconfig.get_config_var("HAVE_UUID_UUID_H")
1775+
if uuid_h or uuid_uuid_h:
1776+
if sysconfig.get_config_var("HAVE_LIBUUID"):
1777+
uuid_libs = ["uuid"]
17771778
else:
17781779
uuid_libs = []
17791780
self.add(Extension('_uuid', ['_uuidmodule.c'],
1780-
libraries=uuid_libs,
1781-
include_dirs=uuid_incs))
1781+
libraries=uuid_libs))
17821782
else:
17831783
self.missing.append('_uuid')
17841784

0 commit comments

Comments
 (0)