Coverage for python/lsst/sconsUtils/eupsForScons.py: 22%
36 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-22 11:01 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-22 11:01 +0000
1import os
3try:
4 # Prefer to use native EUPS but if that is not available, fallback
5 # versions are defined. Only a subset of EUPS functions are required
6 # but all are imported to prevent warnings from redefinitions below.
7 from eups import * # noqa F403 F401
8 eupsLoaded = True
9except ImportError:
10 eupsLoaded = False
13def haveEups():
14 return eupsLoaded
17if not haveEups(): 17 ↛ 21line 17 didn't jump to line 21, because the condition on line 17 was never true
18 #
19 # Fake what we can so sconsUtils can limp along without eups
20 #
21 def flavor():
22 from .state import env, log
24 log.warn("Unable to import eups; guessing flavor")
26 if env['PLATFORM'] == "posix":
27 return os.uname()[0].title()
28 else:
29 return env['PLATFORM'].title()
31 def productDir(name):
32 return os.environ.get("%s_DIR" % name.upper())
34 def findSetupVersion(eupsProduct):
35 return None, None, None, None, flavor()
37 class _Eups:
38 def __call__(self):
39 return self
40 Eups = _Eups()
42 Eups.findSetupVersion = findSetupVersion
44 class _Utils:
45 pass
46 utils = _Utils()
48 def setupEnvNameFor(productName):
49 return "SETUP_%s" % productName
51 utils.setupEnvNameFor = setupEnvNameFor
54def getEups():
55 """Return a cached Eups instance, auto-creating if necessary."""
56 try:
57 return getEups._eups
58 except AttributeError:
59 getEups._eups = Eups()
60 return getEups._eups