Use context manager for open/close

This commit is contained in:
Dominic Kempf 2020-05-14 09:36:52 +02:00
parent fae067a0d7
commit df503f9038
1 changed files with 9 additions and 7 deletions

View File

@ -263,13 +263,15 @@ class Dune(CMakePackage):
def cmake(self, spec, prefix): def cmake(self, spec, prefix):
if self.stage.archive_file: if self.stage.archive_file:
os.remove(self.stage.archive_file) os.remove(self.stage.archive_file)
optFile = open(join_path(self.stage.source_path, "..", "dune.opts"), "w")
optFile.write('CMAKE_FLAGS="') # Write an opts file for later use
for flag in self.cmake_args(): with open(join_path(self.stage.source_path, "..", "dune.opts"), "w") as optFile:
optFile.write(flag.replace("\"", "'")+" ") optFile.write('CMAKE_FLAGS="')
optFile.write('-DCMAKE_INSTALL_PREFIX=%s' % prefix) for flag in self.cmake_args():
optFile.write('"') optFile.write(flag.replace("\"", "'")+" ")
optFile.close() optFile.write('-DCMAKE_INSTALL_PREFIX=%s' % prefix)
optFile.write('"')
set_executable('bin/dunecontrol') set_executable('bin/dunecontrol')
installer = Executable('bin/dunecontrol') installer = Executable('bin/dunecontrol')
options_file = join_path(self.stage.source_path, "..", "dune.opts") options_file = join_path(self.stage.source_path, "..", "dune.opts")