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
This commit is contained in:
Kirill A. Korinsky 2022-04-07 19:12:14 +02:00
parent aefa7cef1b
commit c739be1ba3
No known key found for this signature in database
GPG key ID: 98D8D9867759226E

View file

@ -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