From fae067a0d7eeeaf3906d98fdd7b26d58cdefe289 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Thu, 14 May 2020 09:34:50 +0200 Subject: [PATCH 1/4] Use join_path from spack instead of string concatenation --- packages/dune/package.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/dune/package.py b/packages/dune/package.py index 19764c1..54617b8 100644 --- a/packages/dune/package.py +++ b/packages/dune/package.py @@ -24,8 +24,6 @@ import os from spack import * - - class Dune(CMakePackage): """ DUNE, the Distributed and Unified Numerics Environment is a modular toolbox for solving partial differential equations (PDEs) with grid-based methods. @@ -265,7 +263,7 @@ class Dune(CMakePackage): def cmake(self, spec, prefix): if self.stage.archive_file: os.remove(self.stage.archive_file) - optFile = open(self.stage.source_path+"/../dune.opts", "w") + optFile = open(join_path(self.stage.source_path, "..", "dune.opts"), "w") optFile.write('CMAKE_FLAGS="') for flag in self.cmake_args(): optFile.write(flag.replace("\"", "'")+" ") @@ -274,21 +272,21 @@ class Dune(CMakePackage): optFile.close() set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') - options_file=self.stage.source_path+"/../dune.opts" + options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'cmake') pass def install(self, spec, prefix): set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') - options_file=self.stage.source_path+"/../dune.opts" + options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make', 'install') pass def build(self, spec, prefix): set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') - options_file=self.stage.source_path+"/../dune.opts" + options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make') pass From df503f9038b25913137372ae6c2c7e07c945a7db Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Thu, 14 May 2020 09:36:52 +0200 Subject: [PATCH 2/4] Use context manager for open/close --- packages/dune/package.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/dune/package.py b/packages/dune/package.py index 54617b8..4621eac 100644 --- a/packages/dune/package.py +++ b/packages/dune/package.py @@ -263,13 +263,15 @@ class Dune(CMakePackage): def cmake(self, spec, prefix): if 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="') - for flag in self.cmake_args(): - optFile.write(flag.replace("\"", "'")+" ") - optFile.write('-DCMAKE_INSTALL_PREFIX=%s' % prefix) - optFile.write('"') - optFile.close() + + # Write an opts file for later use + with open(join_path(self.stage.source_path, "..", "dune.opts"), "w") as optFile: + optFile.write('CMAKE_FLAGS="') + for flag in self.cmake_args(): + optFile.write(flag.replace("\"", "'")+" ") + optFile.write('-DCMAKE_INSTALL_PREFIX=%s' % prefix) + optFile.write('"') + set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") From 1c0ec5ad8a519ddc8d2f9760c683722da4c1a42a Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Thu, 14 May 2020 09:39:56 +0200 Subject: [PATCH 3/4] Remove calls to set_executable The dunecontrol script should always be executable, so there is (hopefully) no need of calling this function. --- packages/dune/package.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/dune/package.py b/packages/dune/package.py index 4621eac..11219f0 100644 --- a/packages/dune/package.py +++ b/packages/dune/package.py @@ -272,21 +272,18 @@ class Dune(CMakePackage): optFile.write('-DCMAKE_INSTALL_PREFIX=%s' % prefix) optFile.write('"') - set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'cmake') pass def install(self, spec, prefix): - set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make', 'install') pass def build(self, spec, prefix): - set_executable('bin/dunecontrol') installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make') From 0be0632f45653b74a8de7ee6ee30695c0042bd66 Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Thu, 14 May 2020 09:41:22 +0200 Subject: [PATCH 4/4] Remove superfluous pass statements --- packages/dune/package.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/dune/package.py b/packages/dune/package.py index 11219f0..0dc6a40 100644 --- a/packages/dune/package.py +++ b/packages/dune/package.py @@ -275,19 +275,16 @@ class Dune(CMakePackage): installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'cmake') - pass def install(self, spec, prefix): installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make', 'install') - pass def build(self, spec, prefix): installer = Executable('bin/dunecontrol') options_file = join_path(self.stage.source_path, "..", "dune.opts") installer('--builddir=%s'%self.build_directory , '--opts=%s' % options_file, 'make') - pass @run_after('install') def install_python_components(self):