ATLAS Offline Software
Loading...
Searching...
No Matches
moduleExists.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
8from functools import cache
9import importlib.util
10
11
12@cache
13def moduleExists (modName):
14 """Test for the existence of a module without actually importing it.
15
16We could just do
17 try:
18 import modName
19 except ImportError:
20 ...
21except that that has the potential to hide other errors."""
22
23 return importlib.util.find_spec (modName) is not None