|
49 | 49 | from easybuild.framework.extensioneasyblock import ExtensionEasyBlock |
50 | 50 | from easybuild.tools.build_log import EasyBuildError, print_msg |
51 | 51 | from easybuild.tools.config import build_option, PYTHONPATH, EBPYTHONPREFIXES |
52 | | -from easybuild.tools.filetools import change_dir, mkdir, remove_dir, symlink, which |
| 52 | +from easybuild.tools.filetools import change_dir, mkdir, read_file, remove_dir, symlink, which, write_file |
53 | 53 | from easybuild.tools.modules import ModEnvVarType, get_software_root |
54 | 54 | from easybuild.tools.run import run_shell_cmd |
55 | 55 | from easybuild.tools.utilities import nub |
@@ -860,15 +860,10 @@ def configure_step(self): |
860 | 860 | finaltxt = finaltxt.replace('SITECFGINCDIR', repl) |
861 | 861 |
|
862 | 862 | self.log.debug("Using %s: %s" % (self.sitecfgfn, finaltxt)) |
863 | | - try: |
864 | | - if os.path.exists(self.sitecfgfn): |
865 | | - txt = open(self.sitecfgfn).read() |
866 | | - self.log.debug("Found %s: %s" % (self.sitecfgfn, txt)) |
867 | | - config = open(self.sitecfgfn, 'w') |
868 | | - config.write(finaltxt) |
869 | | - config.close() |
870 | | - except IOError: |
871 | | - raise EasyBuildError("Creating %s failed", self.sitecfgfn) |
| 863 | + if os.path.exists(self.sitecfgfn): |
| 864 | + txt = read_file(self.sitecfgfn) |
| 865 | + self.log.debug("Found %s: %s" % (self.sitecfgfn, txt)) |
| 866 | + write_file(self.sitecfgfn, finaltxt) |
872 | 867 |
|
873 | 868 | # conservatively auto-enable checking of $LDSHARED if it is not explicitely enabled or disabled |
874 | 869 | # only do this for sufficiently recent Python versions (>= 3.7 or Python 2.x >= 2.7.15) |
@@ -1024,7 +1019,7 @@ def install_step(self): |
1024 | 1019 | abs_bindir = os.path.join(actual_installdir, 'bin') |
1025 | 1020 |
|
1026 | 1021 | # set PYTHONPATH and PATH as expected |
1027 | | - old_values = dict() |
| 1022 | + old_values = {} |
1028 | 1023 | for name, new_values in (('PYTHONPATH', abs_pylibdirs), ('PATH', [abs_bindir])): |
1029 | 1024 | old_value = os.getenv(name) |
1030 | 1025 | old_values[name] = old_value |
|
0 commit comments