Coverage for python/lsst/sconsUtils/eupsForScons.py: 35%
36 statements
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-26 19:26 +0000
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-26 19:26 +0000
1# This file is part of sconsUtils.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import os
24try:
25 # Prefer to use native EUPS but if that is not available, fallback
26 # versions are defined. Only a subset of EUPS functions are required
27 # but all are imported to prevent warnings from redefinitions below.
28 from eups import * # noqa F403 F401
30 eupsLoaded = True
31except ImportError:
32 eupsLoaded = False
35def haveEups():
36 return eupsLoaded
39if not haveEups(): 39 ↛ 43line 39 didn't jump to line 43 because the condition on line 39 was never true
40 #
41 # Fake what we can so sconsUtils can limp along without eups
42 #
43 def flavor():
44 from .state import env, log
46 log.warn("Unable to import eups; guessing flavor")
48 if env["PLATFORM"] == "posix":
49 return os.uname()[0].title()
50 else:
51 return env["PLATFORM"].title()
53 def productDir(name):
54 return os.environ.get(f"{name.upper()}_DIR")
56 def findSetupVersion(eupsProduct):
57 return None, None, None, None, flavor()
59 class _Eups:
60 def __call__(self):
61 return self
63 Eups = _Eups()
65 Eups.findSetupVersion = findSetupVersion
67 class _Utils:
68 pass
70 utils = _Utils()
72 def setupEnvNameFor(productName):
73 return f"SETUP_{productName}"
75 utils.setupEnvNameFor = setupEnvNameFor
78def getEups():
79 """Return a cached Eups instance, auto-creating if necessary."""
80 try:
81 return getEups._eups
82 except AttributeError:
83 getEups._eups = Eups()
84 return getEups._eups