[elbe-devel] [PATCH 1/1] Try package distro if platform
Bastian Germann
bage at linutronix.de
Wed Feb 5 21:12:03 CET 2020
Am 03.02.20 um 15:27 schrieb Olivier Dion:
>
> On 2020-02-03T04:13:29-0500, Bastian Germann <bage at linutronix.de> wrote:
>
>> Am 03.02.20 um 02:24 schrieb Olivier Dion:
>> > 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.
>
>> Isn't there a simple way to get the information without importing an
>> additional package?
>
> I would like that solution too. The official doc says to use a package
> like distro, however it would be possible to do it ourself. Looking at
> the original package.linux_distribution, it searchs for files in /etc to
> find the distro version.
We only use the two first elements of the return value. We use it only
in one place, which is `elbe --version` output.
It was add in d2674f30e138178a6f5e80174ffcaf807e5112b8 three years ago.
I would suggest just dropping the system version from the output or
replace it with platform.version().
>
>> > 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
>> >
>> >
>
>
> --
> Olivier Dion
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
More information about the elbe-devel
mailing list