Skip to contentSkip to conversation

python3: use stdlib UUID backend

PATCH New Matt Weber 3 participants 4 messages Oct 12, 2018 – Oct 18, 2018

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH 1/1 python3: use stdlib UUID backend

Python3 at runtime identifies the uuid backend to use to implement functions like uuid_generate_time. This search includes libc first and then other options like util-linux's libuuid. There is also an option to use an extension module, however it looks like that requires the libuuid and headers to be present (./Modules/_uuidmodule.c). The extension isn't required to make this work.

- This was runtime tested by updating the python3-3.7.0/Lib/uuid.py to include debug information in the def _load_system_functions():
to print "libname". Then at runtime it was observed that libc was the selected backend.

- At build time, the log was checked to confirmed the configure step didn't detect any uuid support in both the case of util-linux present and not. However, this did not prevent the uuid runtime from working. Thus the reason the patch 0031-* which adds the opt to disable uuid has no affect.

This patch removes the enable/disable option as it is no longer required since python's use of libc should be possible in every system.
Note: Currently the BR2_PACKAGE_PYTHON3_UUID disable doesn't work to prevent the "import uuid ; print(uuid.uuid1())" example from working at runtime.

This patch drops the dependency on util-linux as the library isn't required for a working python uuid implementation. The enabling of libuuid.so in a Buildroot configuration doesn't currently have any affect on the feature, as python still uses the libc backend.

Ref:
http://lists.busybox.net/pipermail/buildroot/2018-October/233113.html
http://lists.busybox.net/pipermail/buildroot/2018-September/231060.html
http://lists.busybox.net/pipermail/buildroot/2018-October/233079.html

CC Adam Duskett <[email protected]>
CC Adam Duskett <[email protected]>
---
 ...0031-Add-an-option-to-disable-uuid-module.patch | 33 ----------------------
 package/python3/Config.in                          | 10 -------
 package/python3/python3.mk                         |  6 ----
 3 files changed, 49 deletions(-)
 delete mode 100644 package/python3/0031-Add-an-option-to-disable-uuid-module.patch
package/python3/0031-Add-an-option-to-disable-uuid-module.patch deleted +0 -33
deleted file mode 100644
index c429c59..0000000
@@ -1,33 +0,0 @@
-From 1fe33c7bee9e6410f56c956ea19efd2f617176ae Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <[email protected]>
-Date: Sat, 18 Aug 2018 10:54:56 +0200
-Subject: [PATCH] Add an option to disable uuid module
-
-Signed-off-by: Thomas Petazzoni <[email protected]>
----
- configure.ac | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/configure.ac b/configure.ac
-index b022460e73..505b7c9be0 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -3258,6 +3258,15 @@ if test "$CURSES" = "no"; then
-    DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _curses _curses_panel"
- fi
- 
-+AC_SUBST(UUID)
-+AC_ARG_ENABLE(uuid,
-+	AS_HELP_STRING([--disable-uuid], [disable uuid]),
-+	[ UUID="${enableval}" ], [ UUID=yes ])
-+
-+if test "$UUID" = "no"; then
-+   DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _uuid"
-+fi
-+
- AC_SUBST(PYDOC)
- 
- AC_ARG_ENABLE(pydoc,
--- 
-2.14.4
-
package/python3/Config.in +0 -10
index 0701d56..623fefe 100644
@@ -88,16 +88,6 @@ config BR2_PACKAGE_PYTHON3_UNICODEDATA
 	  Unicode character database (used by stringprep module)
 	  (large).
 
-config BR2_PACKAGE_PYTHON3_UUID
-	bool "uuid module"
-	select BR2_PACKAGE_UTIL_LINUX
-	select BR2_PACKAGE_UTIL_LINUX_LIBUUID
-	help
-	  This module provides immutable UUID objects (the UUID class)
-	  and the functions uuid1(), uuid3(), uuid4(), uuid5() for
-	  generating version 1, 3, 4, and 5 UUIDs as specified in RFC
-	  4122.
-
 config BR2_PACKAGE_PYTHON3_SQLITE
 	bool "sqlite module"
 	select BR2_PACKAGE_SQLITE
package/python3/python3.mk +0 -6
index 0c46806..71f5226 100644
@@ -94,12 +94,6 @@ ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
 PYTHON3_CONF_OPTS += --disable-unicodedata
 endif
 
-ifeq ($(BR2_PACKAGE_PYTHON3_UUID),y)
-PYTHON3_DEPENDENCIES += util-linux
-else
-#PYTHON3_CONF_OPTS += --disable-uuid
-endif
-
 ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
 PYTHON3_DEPENDENCIES += bzip2
 else
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/1 python3: use stdlib UUID backend

In reply to Matt Weber

Hello,

Quoted 26 lines · Matt Weber
package/python3/0031-Add-an-option-to-disable-uuid-module.patch deleted +0 -20
deleted file mode 100644
index c429c59..0000000
@@ -1,33 +0,0 @@
-From 1fe33c7bee9e6410f56c956ea19efd2f617176ae Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <[email protected]>
-Date: Sat, 18 Aug 2018 10:54:56 +0200
-Subject: [PATCH] Add an option to disable uuid module
-
-Signed-off-by: Thomas Petazzoni <[email protected]>
----
- configure.ac | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/configure.ac b/configure.ac
-index b022460e73..505b7c9be0 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -3258,6 +3258,15 @@ if test "$CURSES" = "no"; then
-    DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _curses _curses_panel"
- fi
- 
-+AC_SUBST(UUID)
-+AC_ARG_ENABLE(uuid,

package/python3/0031-Add-an-option-to-disable-uuid-module.patch line 30

Quoted 10 lines
package/python3/0031-Add-an-option-to-disable-uuid-module.patch deleted +0 -10
-+	AS_HELP_STRING([--disable-uuid], [disable uuid]),
-+	[ UUID="${enableval}" ], [ UUID=yes ])
-+
-+if test "$UUID" = "no"; then
-+   DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _uuid"
-+fi
-+
- AC_SUBST(PYDOC)
- 
- AC_ARG_ENABLE(pydoc,

I am not sure it is a good idea to drop this patch. Indeed, without this patch, Python will auto-detect the presence of util-linux (if it gets built before), and use it. This means that we don't have the same Python configuration depending on whether util-linux is built before Python or not.

Keeping the patch would allow to pass an unconditional --disable-uuid.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 1/1 python3: use stdlib UUID backend

Thomas,

Quoted 48 lines · Thomas Petazzoni

Hello,

Quoted 26 lines · Matt Weber
package/python3/0031-Add-an-option-to-disable-uuid-module.patch deleted +0 -20
deleted file mode 100644
index c429c59..0000000
@@ -1,33 +0,0 @@
-From 1fe33c7bee9e6410f56c956ea19efd2f617176ae Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <[email protected]>
-Date: Sat, 18 Aug 2018 10:54:56 +0200
-Subject: [PATCH] Add an option to disable uuid module
-
-Signed-off-by: Thomas Petazzoni <[email protected]>
----
- configure.ac | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/configure.ac b/configure.ac
-index b022460e73..505b7c9be0 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -3258,6 +3258,15 @@ if test "$CURSES" = "no"; then
-    DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _curses _curses_panel"
- fi
-
-+AC_SUBST(UUID)
-+AC_ARG_ENABLE(uuid,

package/python3/0031-Add-an-option-to-disable-uuid-module.patch line 30

Quoted 10 lines
package/python3/0031-Add-an-option-to-disable-uuid-module.patch deleted +0 -10
-+    AS_HELP_STRING([--disable-uuid], [disable uuid]),
-+    [ UUID="${enableval}" ], [ UUID=yes ])
-+
-+if test "$UUID" = "no"; then
-+   DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _uuid"
-+fi
-+
- AC_SUBST(PYDOC)
-
- AC_ARG_ENABLE(pydoc,

I am not sure it is a good idea to drop this patch. Indeed, without this patch, Python will auto-detect the presence of util-linux (if it gets built before), and use it. This means that we don't have the same Python configuration depending on whether util-linux is built before Python or not.

Quoted 2 lines

Keeping the patch would allow to pass an unconditional --disable-uuid.

Ah ic, I didn't think about the order of the auto-detect. I agree the patch should stay and a unconditional --disable-uuid should be passed but a note added stating uuid support falls back to libc when util-linux isn't present.

Matt