From c739be1ba3196148c571c057d0765411aa1993b9 Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" Date: Thu, 7 Apr 2022 19:12:14 +0200 Subject: [PATCH] Do not fail if the package is not installed Here a naive approach which prevents a fail if this code is used without installing. Fixes: https://github.com/pylast/pylast/issues/397 --- src/pylast/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index e152c31..971a6c8 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -47,8 +47,10 @@ __author__ = "Amr Hassan, hugovk, Mice Pápai" __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2021 hugovk, 2017 Mice Pápai" __license__ = "apache2" __email__ = "amr.hassan@gmail.com" -__version__ = importlib_metadata.version(__name__) - +try: + __version__ = importlib_metadata.version("x") +except importlib_metadata.PackageNotFoundError: + __version__ = "n/a" # 1 : This error does not exist STATUS_INVALID_SERVICE = 2