Skip to content

Commit 77a1f8d

Browse files
authored
bpo-43158: Use configure values for building _uuid extension (GH-29353)
1 parent 3409899 commit 77a1f8d

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
@@ -10159,6 +10159,75 @@ $as_echo "no" >&6; }
1015910159
fi
1016010160
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1016110161

10162+
save_LIBS=$LIBS
10163+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uuid_generate_time_safe" >&5
10164+
$as_echo_n "checking for library containing uuid_generate_time_safe... " >&6; }
10165+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10166+
$as_echo_n "(cached) " >&6
10167+
else
10168+
ac_func_search_save_LIBS=$LIBS
10169+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10170+
/* end confdefs.h. */
10171+
10172+
/* Override any GCC internal prototype to avoid an error.
10173+
Use char because int might match the return type of a GCC
10174+
builtin and then its argument prototype would still apply. */
10175+
#ifdef __cplusplus
10176+
extern "C"
10177+
#endif
10178+
char uuid_generate_time_safe ();
10179+
int
10180+
main ()
10181+
{
10182+
return uuid_generate_time_safe ();
10183+
;
10184+
return 0;
10185+
}
10186+
_ACEOF
10187+
for ac_lib in '' uuid; do
10188+
if test -z "$ac_lib"; then
10189+
ac_res="none required"
10190+
else
10191+
ac_res=-l$ac_lib
10192+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
10193+
fi
10194+
if ac_fn_c_try_link "$LINENO"; then :
10195+
ac_cv_search_uuid_generate_time_safe=$ac_res
10196+
fi
10197+
rm -f core conftest.err conftest.$ac_objext \
10198+
conftest$ac_exeext
10199+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10200+
break
10201+
fi
10202+
done
10203+
if ${ac_cv_search_uuid_generate_time_safe+:} false; then :
10204+
10205+
else
10206+
ac_cv_search_uuid_generate_time_safe=no
10207+
fi
10208+
rm conftest.$ac_ext
10209+
LIBS=$ac_func_search_save_LIBS
10210+
fi
10211+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uuid_generate_time_safe" >&5
10212+
$as_echo "$ac_cv_search_uuid_generate_time_safe" >&6; }
10213+
ac_res=$ac_cv_search_uuid_generate_time_safe
10214+
if test "$ac_res" != no; then :
10215+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
10216+
10217+
10218+
$as_echo "#define HAVE_LIBUUID 1" >>confdefs.h
10219+
,
10220+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10221+
$as_echo "yes" >&6; }
10222+
10223+
else
10224+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10225+
$as_echo "no" >&6; }
10226+
10227+
fi
10228+
10229+
LIBS=$save_LIBS
10230+
1016210231
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
1016310232
# FreeBSD and OpenBSD provides support as well
1016410233
{ $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
@@ -2945,8 +2945,13 @@ void *x = uuid_generate_time_safe
29452945
[AC_MSG_RESULT(no)]
29462946
)
29472947

2948+
# check for libuuid from util-linux
2949+
save_LIBS=$LIBS
2950+
AC_CHECK_LIB([uuid], [uuid_generate_time])
2951+
LIBS=$save_LIBS
2952+
29482953
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
2949-
# FreeBSD and OpenBSD provides support as well
2954+
# FreeBSD and OpenBSD provides support in libc as well.
29502955
AC_MSG_CHECKING(for uuid_create)
29512956
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
29522957
#ifndef uuid_create

pyconfig.h.in

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

607+
/* Define you have libuuid. */
608+
#undef HAVE_LIBUUID
609+
607610
/* Define if you have the 'link' function. */
608611
#undef HAVE_LINK
609612

setup.py

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

18431843
def detect_uuid(self):
18441844
# Build the _uuid module if possible
1845-
uuid_incs = find_file("uuid.h", self.inc_dirs, ["/usr/include/uuid"])
1846-
if uuid_incs is not None:
1847-
if self.compiler.find_library_file(self.lib_dirs, 'uuid'):
1848-
uuid_libs = ['uuid']
1845+
uuid_h = sysconfig.get_config_var("HAVE_UUID_H")
1846+
uuid_uuid_h = sysconfig.get_config_var("HAVE_UUID_UUID_H")
1847+
if uuid_h or uuid_uuid_h:
1848+
if sysconfig.get_config_var("HAVE_LIBUUID"):
1849+
uuid_libs = ["uuid"]
18491850
else:
18501851
uuid_libs = []
18511852
self.add(Extension('_uuid', ['_uuidmodule.c'],
1852-
libraries=uuid_libs,
1853-
include_dirs=uuid_incs))
1853+
libraries=uuid_libs))
18541854
else:
18551855
self.missing.append('_uuid')
18561856

0 commit comments

Comments
 (0)