Coverage for python/lsst/sconsUtils/eupsForScons.py: 22%

36 statements  

« prev     ^ index     » next       coverage.py v7.17.5, created at 2026-11-26 06:33 +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/>. 

21 

22import os 

23 

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 

29 

30 eupsLoaded = True 

31except ImportError: 

32 eupsLoaded = False 

33 

34 

35def haveEups(): 

36 return eupsLoaded 

37 

38 

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 

45 

46 log.warn("Unable to import eups; guessing flavor") 

47 

48 if env["PLATFORM"] == "posix": 

49 return os.uname()[0].title() 

50 else: 

51 return env["PLATFORM"].title() 

52 

53 def productDir(name): 

54 return os.environ.get(f"{name.upper()}_DIR") 

55 

56 def findSetupVersion(eupsProduct): 

57 return None, None, None, None, flavor() 

58 

59 class _Eups: 

60 def __call__(self): 

61 return self 

62 

63 Eups = _Eups() 

64 

65 Eups.findSetupVersion = findSetupVersion 

66 

67 class _Utils: 

68 pass 

69 

70 utils = _Utils() 

71 

72 def setupEnvNameFor(productName): 

73 return f"SETUP_{productName}" 

74 

75 utils.setupEnvNameFor = setupEnvNameFor 

76 

77 

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