Skip to content

Commit 90037b1

Browse files
authored
Merge pull request #2531 from priv-kweihmann/fix/DistributionNotFound
scancode_config: improve DistributionNotFound
2 parents 0969712 + b5e4a19 commit 90037b1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/scancode_config.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ def _create_dir(location):
7272
# current installation location. This is where the source code and static data
7373
# lives.
7474

75-
75+
# in case package is not installed or we do not have setutools/pkg_resources
76+
# on hand fall back to this version
77+
__version__ = '21.3.31'
7678
try:
7779
from pkg_resources import get_distribution, DistributionNotFound
78-
__version__ = get_distribution('scancode-toolkit').version
79-
except (DistributionNotFound, ImportError):
80-
# package is not installed or we do not have setutools/pkg_resources
81-
# on hand
82-
__version__ = '21.3.31'
80+
try:
81+
__version__ = get_distribution('scancode-toolkit').version
82+
except DistributionNotFound:
83+
pass
84+
except ImportError:
85+
pass
8386

8487
system_temp_dir = tempfile.gettempdir()
8588
scancode_src_dir = dirname(__file__)

0 commit comments

Comments
 (0)