def install(self, spec, prefix): """Install under the projectdir""" # Fairly ugly since intermediate targets are scattered inside sources appdir = 'applications' projdir = os.path.basename(self.projectdir) mkdirp(self.projectdir, join_path(self.projectdir, appdir)) # Filtering: bashrc, cshrc edits = { 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), } # All top-level files, except spack build info and possibly Allwmake if '+source' in spec: ignored = re.compile(r'^spack-.*') else: ignored = re.compile(r'^(Allclean|Allwmake|spack-).*') files = [ f for f in glob.glob("*") if os.path.isfile(f) and not ignored.search(f) ] for f in files: install(f, self.projectdir) # Install directories. install applications/bin directly # Install 'etc' before 'bin' (for symlinks) for d in ['etc', 'bin', 'wmake', 'lib', join_path(appdir, 'bin')]: install_tree(d, join_path(self.projectdir, d), symlinks=True) if '+source' in spec: subitem = join_path(appdir, 'Allwmake') install(subitem, join_path(self.projectdir, subitem)) foam_arch_str = str(self.foam_arch) # Ignore intermediate targets ignore = lambda p: os.path.basename(p) == foam_arch_str for d in ['src', 'tutorials']: install_tree(d, join_path(self.projectdir, d), ignore=ignore, symlinks=True) for d in ['solvers', 'utilities']: install_tree(join_path(appdir, d), join_path(self.projectdir, appdir, d), ignore=ignore, symlinks=True) etc_dir = join_path(self.projectdir, 'etc') rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path(etc_dir, 'bashrc'), cshell=join_path(etc_dir, 'cshrc')) self.install_links()
def configure(self, spec, prefix): """Make adjustments to the OpenFOAM configuration files in their various locations: etc/bashrc, etc/config.sh/FEATURE and customizations that don't properly fit get placed in the etc/prefs.sh file (similiarly for csh). """ # Filtering bashrc, cshrc edits = {} edits.update(self.foam_arch.foam_dict()) rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path('etc', 'bashrc'), cshell=join_path('etc', 'cshrc')) # MPI content, with absolute paths user_mpi = mplib_content(spec) # Content for etc/prefs.{csh,sh} self.etc_prefs = { r'MPI_ROOT': spec['mpi'].prefix, # Absolute r'MPI_ARCH_FLAGS': '"%s"' % user_mpi['FLAGS'], r'MPI_ARCH_INC': '"%s"' % user_mpi['PINC'], r'MPI_ARCH_LIBS': '"%s"' % user_mpi['PLIBS'], } # Content for etc/config.{csh,sh}/ files self.etc_config = { 'CGAL': {}, 'scotch': {}, 'metis': {}, 'paraview': [], 'gperftools': [], # Currently unused } if True: self.etc_config['scotch'] = { 'SCOTCH_ARCH_PATH': spec['scotch'].prefix, # For src/parallel/decompose/Allwmake 'SCOTCH_VERSION': 'scotch-{0}'.format(spec['scotch'].version), } # Write prefs files according to the configuration. # Only need prefs.sh for building, but install both for end-users if self.etc_prefs: write_environ( self.etc_prefs, posix=join_path('etc', 'prefs.sh'), cshell=join_path('etc', 'prefs.csh')) # Adjust components to use SPACK variants for component, subdict in self.etc_config.items(): write_environ( subdict, posix=join_path('etc', 'config.sh', component), cshell=join_path('etc', 'config.csh', component))
def install(self, spec, prefix): """Install under the projectdir""" mkdirp(self.projectdir) projdir = os.path.basename(self.projectdir) # Filtering: bashrc, cshrc edits = { 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), } # All top-level files, except spack build info and possibly Allwmake if '+source' in spec: ignored = re.compile(r'^spack-.*') else: ignored = re.compile(r'^(Allwmake|spack-).*') files = [ f for f in glob.glob("*") if os.path.isfile(f) and not ignored.search(f) ] for f in files: install(f, self.projectdir) # Having wmake and ~source is actually somewhat pointless... # Install 'etc' before 'bin' (for symlinks) dirs = ['etc', 'bin', 'wmake'] if '+source' in spec: dirs.extend(['applications', 'src', 'tutorials']) for d in dirs: install_tree( d, join_path(self.projectdir, d), symlinks=True) dirs = ['platforms'] if '+source' in spec: dirs.extend(['doc']) # Install platforms (and doc) skipping intermediate targets ignored = ['src', 'applications', 'html', 'Guides'] for d in dirs: install_tree( d, join_path(self.projectdir, d), ignore=shutil.ignore_patterns(*ignored), symlinks=True) etc_dir = join_path(self.projectdir, 'etc') rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path(etc_dir, 'bashrc'), cshell=join_path(etc_dir, 'cshrc')) self.install_links()
def patch(self): """Adjust OpenFOAM build for spack. Where needed, apply filter as an alternative to normal patching.""" self.rename_source() add_extra_files(self, self.common, self.assets) # Avoid WM_PROJECT_INST_DIR for ThirdParty, site or jobControl. # Use openfoam-site.patch to handle jobControl, site. # # Filtering: bashrc,cshrc (using a patch is less flexible) edits = { 'WM_THIRD_PARTY_DIR': r'$WM_PROJECT_DIR/ThirdParty #SPACK: No separate third-party', 'WM_VERSION': str(self.version), # consistency 'FOAMY_HEX_MESH': '', # This is horrible (unset variable?) } rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path('etc', 'bashrc'), cshell=join_path('etc', 'cshrc'))
def install(self, spec, prefix): """Install under the projectdir""" # Fairly ugly since intermediate targets are scattered inside sources appdir = 'applications' projdir = os.path.basename(self.projectdir) mkdirp(self.projectdir, join_path(self.projectdir, appdir)) # Filtering: bashrc, cshrc edits = { 'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir), 'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir), } # All top-level files, except spack build info and possibly Allwmake if '+source' in spec: ignored = re.compile(r'^spack-.*') else: ignored = re.compile(r'^(Allclean|Allwmake|spack-).*') files = [ f for f in glob.glob("*") if os.path.isfile(f) and not ignored.search(f) ] for f in files: install(f, self.projectdir) # Install directories. install applications/bin directly # Install 'etc' before 'bin' (for symlinks) for d in ['etc', 'bin', 'wmake', 'lib', join_path(appdir, 'bin')]: install_tree( d, join_path(self.projectdir, d), symlinks=True) if '+source' in spec: subitem = join_path(appdir, 'Allwmake') install(subitem, join_path(self.projectdir, subitem)) foam_arch_str = str(self.foam_arch) # Ignore intermediate targets ignore = lambda p: os.path.basename(p) == foam_arch_str for d in ['src', 'tutorials']: install_tree( d, join_path(self.projectdir, d), ignore=ignore, symlinks=True) for d in ['solvers', 'utilities']: install_tree( join_path(appdir, d), join_path(self.projectdir, appdir, d), ignore=ignore, symlinks=True) etc_dir = join_path(self.projectdir, 'etc') rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc edits, posix=join_path(etc_dir, 'bashrc'), cshell=join_path(etc_dir, 'cshrc')) self.install_links()