[elbe-devel] [PATCH 1/1] Try package distro if platform

Olivier Dion dion at linutronix.de
Mon Feb 3 02:24:13 CET 2020


platform.linux_distribution is deprecated since 3.5 and removed in
3.8, see <https://docs.python.org/2/library/platform.html#platform.linux_distribution>.

Since this is only the case with Py3, the distro package was added to
the dependencies of python3-elbe-common.

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 debian/control      | 1 +
 elbepack/version.py | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index e11754a71..363d2032e 100644
--- a/debian/control
+++ b/debian/control
@@ -83,6 +83,7 @@ Depends: ${misc:Depends},
   elbe-schema (= ${binary:Version}),
   python3-elbe-bin (= ${binary:Version}),
   python3,
+  python3-distro,
   python3-lxml,
   python3-apt,
   python3-gpg,
diff --git a/elbepack/version.py b/elbepack/version.py
index 0dfe7cddb..b9da8820d 100644
--- a/elbepack/version.py
+++ b/elbepack/version.py
@@ -4,7 +4,11 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-from platform import linux_distribution
+# platform.linux_distribution is deprecated since 3.5 and removed in 3.8
+try:
+    from platform import linux_distribution
+except ImportError:
+    from distro import linux_distribution
 
 from elbepack.directories import pack_dir
 
-- 
2.25.0




More information about the elbe-devel mailing list