File: Ignore-PackageNotFoundError-when-trying-to-set-__version_.patch

package info (click to toggle)
glueviz 1.24.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,828 kB
  • sloc: python: 31,059; makefile: 133; sh: 8
file content (26 lines) | stat: -rw-r--r-- 777 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From: Ole Streicher <olebole@debian.org>
Date: Wed, 12 Nov 2025 15:40:17 +0100
Subject: Ignore PackageNotFoundError when trying to set __version__

During build time test the package is not installed yet, and this should
not fail.
---
 glue/__init__.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/glue/__init__.py b/glue/__init__.py
index a45ad1a..e9ec2d5 100644
--- a/glue/__init__.py
+++ b/glue/__init__.py
@@ -8,7 +8,10 @@ import sys
 
 import importlib.metadata
 
-__version__ = importlib.metadata.version('glue-core')
+try:
+    __version__ = importlib.metadata.version('glue-core')
+except importlib.metadata.PackageNotFoundError:
+    pass
 
 from ._mpl_backend import MatplotlibBackendSetter
 sys.meta_path.append(MatplotlibBackendSetter())