def install(self, spec, prefix): # edit cns_solve_environment to allow a build shutil.copy('cns_solve_env', 'cns_solve_env.back') filter_file(r"setenv CNS_SOLVE '_CNSsolve_location_'", f"setenv CNS_SOLVE '{self.stage.source_path}'", 'cns_solve_env') # copy over an almost right machine make file we could have got it from v1.3 but this is simpler src_file = 'instlib/machine/supported/intel-x86_64bit-linux/Makefile.header.2.gfortran' dest_file = 'instlib/machine/supported/mac-intel-darwin/Makefile.header.5.gfortran' shutil.move(src_file, dest_file) if not self.spec.satisfies('%fortran@:10.0.0'): # patch the machine make file, can't be done with a patch statement it doesn't exists till we copy it # tried just copying the file from the package directory but it caused a lockup patch = which('patch') patch_file = join_path( package_root, 'nmrpack/packages/cns', 'gfortran_10_allow_argument_mismatch.patch') patch('-p1', '-i', patch_file) if '+aria' in self.spec: from_path = pathlib.Path('aria2.3/cns/src') to_path = 'source' for target_file in from_path.iterdir(): if target_file.is_file() and target_file.suffix in ('.f', '.inc'): print(f'copying {target_file} to {to_path}') shutil.copy(target_file, to_path) if target_file.is_dir(): print(f'copying {target_file} to {to_path}') shutil.copytree(target_file, join_path(to_path, target_file.name)) shutil.copytree(from_path, 'aria2.3_patches_applied') shutil.rmtree('aria2.3') make('install') install_tree('.', prefix) with working_dir(prefix): shutil.move('cns_solve_env.back', 'cns_solve_env') replacement_env = f" setenv CNS_SOLVE '{prefix}'" filter_file(r"setenv CNS_SOLVE '_CNSsolve_location_'", replacement_env, 'cns_solve_env') # remove a leftover from our previous edits os.remove(pathlib.Path(prefix) / pathlib.Path('cns_solve_env' + '~'))
class Genie(Package): # Genie doesn"t use Autotools """Genie is a neutrino Monte Carlo Generator.""" homepage = "https://www.genie-mc.org" url = "https://github.com/GENIE-MC/Generator/archive/R-3_00_06.tar.gz" git = "https://github.com/GENIE-MC/Generator.git" tags = ["neutrino", "hep"] maintainers = [ # maintainer of this recipe, not affliated with the GENIE collaboration "davehadley", ] version("master", branch="master") version("3.0.6", sha256= "ab56ea85d0c1d09029254365bfe75a1427effa717389753b9e0c1b6c2eaa5eaf") version("3.0.4", sha256= "53f034618fef9f7f0e17d1c4ed72743e4bba590e824b795177a1a8a8486c861e") version("3.0.2", sha256= "34d6c37017b2387c781aea7bc727a0aac0ef45d6b3f3982cc6f3fc82493f65c3") version("3.0.0", sha256= "3953c7d9f1f832dd32dfbc0b9260be59431206c204aec6ab0aa68c01176f2ae6") version("2.12.10", sha256= "c8762db3dcc490f80f8a61268f5b964d4d35b80134b622e89fe2307a836f2a0b") version("2.12.8", sha256= "7ca169a8d9eda7267d28b76b2f3110552852f8eeae263a03cd5139caacebb4ea") version("2.12.6", sha256= "3b450c609875459798ec98e12cf671cc971cbb13345af6d75bd6278d422f3309") version("2.12.4", sha256= "19a4a1633b0847a9f16a44e0c74b9c224ca3bb93975aecf108603c22e807517b") version("2.12.2", sha256= "cbdc45a739878940dadcaaed575b5cad6b5e7035f29605045b1ca557e6faa6d1") version("2.12.0", sha256= "d2b01c80f38d269cb0296b3f2932798ef3f1d51bd130e81274fbfeeb381fac6b") version("2.11.2", sha256= "0f4c25d8ceb7513553671643c9cdac5aa98c40fc8594a5ecb25c077c6b36166e") version("2.11.0", sha256= "1ebe0eb65d797595413632f1cec1cb2621cb8e8d0384a2843799724a79b1d80c") version("2.10.10", sha256= "1dfaadcf1bbaf6e164b612f410c4399301e63497ad6a4891706b1787ac11a7a1") version("2.10.8", sha256= "4f6f5af2062e7c505b76e70547ac2ae304a9790c3e9b9592818d8aebeebc8398") version("2.10.6", sha256= "d00b4288c886f81459fb2967e539f30315d4385f82d1d3f4330298d313f9a176") version("2.10.4", sha256= "df909bf7e1a789ca01794995687da2af803769f0823273a4a3a31678d6d5b0f1") version("2.10.2", sha256= "6abe4e0cdb5e8f5beddf0ccdbebc94c175a9f72592b1cbbffe01b88ee3972bf9") version("2.10.0", sha256= "17bda900c996b6f4f10a7f6a3be94e56c3b8dcdeb2ef8865ca7f20c5fe725291") version("2.9.0", sha256= "8229beb73f65f5af86a77bf141acfbe4a8b68cba9d797aae083a929906f6f2a2") version("2.8.6", sha256= "310dc8e0d17a65e6b9773e398250703a3a6f94ceafe94f599ae0f7b3fecf7e6c") depends_on("root+pythia6") depends_on("pythia6") depends_on("lhapdf", when="@3:") depends_on("lhapdf5", when="@:2") depends_on("log4cpp") depends_on("libxml2") depends_on("gsl") # GENIE does not actually require cmake, but root does. # Spack's concretizer fails with "unsatisfiable constraint" if we don't add this. depends_on("cmake@3:") # GENIE Makefile's think that the spack compiler is invalid. # Disables this check. patch("genie_disable_gopt_with_compiler_check.patch", level=0, when="@2.11:") # Flags for GENIE"s optional but disabled by default features variant( "atmo", default=False, description="Enable GENIE Atmospheric neutrino event generation app") variant( "fnal", default=False, description="Enables FNAL experiment-specific event generation app") variant("nucleondecay", default=False, description="Enable GENIE Nucleon decay event generation app") variant("masterclass", default=False, description="Enable GENIE neutrino masterclass app") variant("t2k", default=False, description="Enable T2K-specific generation app") variant( "vleextension", default=False, description="Enable GENIE very low energy (1 MeV - 100 MeV) extension") phases = ["configure", "build", "install"] def url_for_version(self, version): url = "https://github.com/GENIE-MC/Generator/archive/R-{0}.tar.gz" if version >= Version(3): return url.format("{0}_{1:02d}_{2:02d}".format(*version)) else: return url.format(version.underscored) def setup_build_environment(self, env): env.set("GENIE", self.stage.source_path) return super(Genie, self).setup_build_environment(env) def setup_run_environment(self, env): env.set("GENIE", self.prefix) return super(Genie, self).setup_run_environment(env) def configure(self, spec, prefix): configure = Executable("./configure") args = self._configure_args(spec, prefix) configure(*args) def build(self, spec, prefix): # parallel build is not supported on GENIE 2 self._make(parallel=spec.satisfies("@3:")) def install(self, spec, prefix): # GENIE make install does not support parallel jobs self._make("install", parallel=False) # GENIE requires these files to be present at runtime, but doesn"t install them # so we must install them ourselves # install_tree function is injected into scope by spack build_environment.py install_tree("config", os.sep.join((prefix, "config"))) install_tree("data", os.sep.join((prefix, "data"))) def _configure_args(self, spec, prefix): args = [ "--prefix=" + prefix, "--with-compiler=" + os.environ["CC"], "--with-libxml2-inc={0}{1}libxml2".format( spec["libxml2"].prefix.include, os.sep), "--with-libxml2-lib=" + spec["libxml2"].prefix.lib, "--with-log4cpp-inc=" + spec["log4cpp"].prefix.include, "--with-log4cpp-lib=" + spec["log4cpp"].prefix.lib, "--with-pythia6-lib=" + spec["pythia6"].prefix.lib, ] if self.spec.satisfies("@:2"): args += [ "--enable-lhapdf", "--with-lhapdf-inc=" + spec["lhapdf5"].prefix.include, "--with-lhapdf-lib=" + spec["lhapdf5"].prefix.lib, # must be enabled or some GENIE 2 versions fail to link # this option was removed in GENIE 3 "--enable-rwght", ] else: args += [ "--enable-lhapdf6", "--with-lhapdf6-inc=" + spec["lhapdf"].prefix.include, "--with-lhapdf6-lib=" + spec["lhapdf"].prefix.lib, ] if "+vleextension" in self.spec: args += ["--enable-vle-extension"] if "+t2k" in self.spec: args += ["--enable-t2k"] if "+fnal" in self.spec: args += ["--enable-fnal"] if "+atmo" in self.spec: args += ["--enable-atmo"] if "+nucleondecay" in self.spec: args += ["--enable-nucleon-decay"] if "+masterclass" in self.spec: args += ["--enable-masterclass"] return args def _make(self, *args, **kwargs): parallel = kwargs.get("parallel", False) args = list(self._make_args) + list(args) # make function is injected into scope by spack build_environment.py make(*args, parallel=parallel) @property def _make_args(self): return [ "CC=c++", "CXX=c++", "LD=c++", ]
class Cns(Package): """CNS The Crystallography & NMR System for structure calculation (1.2 for ARIA + aria patches)""" # FIXME: Add a proper url for your package's homepage here. homepage = "http://cns-online.org" url = "http://cns-online.org/download/v1.21/cns_solve_1.21_all-mp.tar.gz" read_releases('cns', version, resource) # patch to make SETFPEPS (set floating point epsilon work) # see https://ask.bioexcel.eu/t/cns-errors-before-after-recompilation/54 # main patch courtesy of Brian Smith U of Glasgow variant('configuration', default='none', description='where to find the configuration file', validator=check_config_file) variant('fp_epsilon', default=True, description='SETFPEPS required for modern compilers') variant('aria', default=True, description='patches required to run aria') resource( name='aria2.3.2', aria_url='http://aria.pasteur.fr/archives/aria2.3.2.tar.gz', sha256= 'a06e9c256bf876f8bbab244a80b9c52bbd891f14cb956d85bb3bd0312b5cd5c6', destination='.') patch('getarch_darwin_x86_64.patch', when='@1.21', sha256= '42a0d10d7684000d5c4cf1114e14d5549cc19c84b19df4d42419abd7187cf887') patch('machvar_fpeps.patch', when='@1.21+fp_epsilon', sha256= 'a00db99086c63961abe4e19d253590421973a80a9e104ac85dbcc07d472b6485') def install(self, spec, prefix): # edit cns_solve_environment to allow a build shutil.copy('cns_solve_env', 'cns_solve_env.back') filter_file(r"setenv CNS_SOLVE '_CNSsolve_location_'", f"setenv CNS_SOLVE '{self.stage.source_path}'", 'cns_solve_env') # copy over an almost right machine make file we could have got it from v1.3 but this is simpler src_file = 'instlib/machine/supported/intel-x86_64bit-linux/Makefile.header.2.gfortran' dest_file = 'instlib/machine/supported/mac-intel-darwin/Makefile.header.5.gfortran' shutil.move(src_file, dest_file) if not self.spec.satisfies('%fortran@:10.0.0'): # patch the machine make file, can't be done with a patch statement it doesn't exists till we copy it # tried just copying the file from the package directory but it caused a lockup patch = which('patch') patch_file = join_path( package_root, 'nmrpack/packages/cns', 'gfortran_10_allow_argument_mismatch.patch') patch('-p1', '-i', patch_file) if '+aria' in self.spec: from_path = pathlib.Path('aria2.3/cns/src') to_path = 'source' for target_file in from_path.iterdir(): if target_file.is_file() and target_file.suffix in ('.f', '.inc'): print(f'copying {target_file} to {to_path}') shutil.copy(target_file, to_path) if target_file.is_dir(): print(f'copying {target_file} to {to_path}') shutil.copytree(target_file, join_path(to_path, target_file.name)) shutil.copytree(from_path, 'aria2.3_patches_applied') shutil.rmtree('aria2.3') make('install') install_tree('.', prefix) with working_dir(prefix): shutil.move('cns_solve_env.back', 'cns_solve_env') replacement_env = f" setenv CNS_SOLVE '{prefix}'" filter_file(r"setenv CNS_SOLVE '_CNSsolve_location_'", replacement_env, 'cns_solve_env') # remove a leftover from our previous edits os.remove(pathlib.Path(prefix) / pathlib.Path('cns_solve_env' + '~')) @run_after('install') @on_package_attributes(run_tests=True) def test(self): try: import tempfile with tempfile.TemporaryDirectory() as tmp_dir_name: tmp_dir_name = '/tmp' test_inp = f''' stop ''' with open(join_path(tmp_dir_name, 'test.inp'), 'w') as fp: fp.write(test_inp) test_csh = f''' source {self.prefix}/cns_solve_env cns_solve < {tmp_dir_name}/test.inp >& {tmp_dir_name}/test_output.txt ''' with open(join_path(tmp_dir_name, 'test.csh'), 'w') as fp: fp.write(test_csh) csh(join(tmp_dir_name, 'test.csh')) expected = ''' ============================================================ | | | Crystallography & NMR System (CNS) | | CNSsolve | | | ============================================================ Version: 1.2 at patch level 1 Status: General release with ARIA enhancements ============================================================ '''.split("\n") expected = [line.strip() for line in expected if len(line)] ok = True result = '' with open(f"{tmp_dir_name}/test_output.txt", 'r') as file_handle: result = file_handle.readlines() result = [line.strip() for line in result if len(line)] for line in expected: if not line in result: tty.error(f'line --{line}-- not in result') ok = False break if not ok: tty.error(f'''during testing strings {expected} not found in test output") ''') tty.error("") tty.error(f" output was") tty.error("") for line in result: tty.error(line.strip()) except Exception as e: tty.error('there was an error', e) def setup_run_environment(self, env): environment_changes = get_environment_change(self.prefix, CNS_SOLVE_ENV) # print('** environment_changes **', environment_changes) # for name, type, value in environment_changes: if type == PREPEND: env.prepend_path(name, value) elif type == NEW: env.set(name, value) else: raise Exception(f'unexpected change type {type}')
class Nuwro(MakefilePackage): """NuWro is a Monte Carlo neutrino event generator.""" homepage = "https://nuwro.github.io/user-guide/" url = "https://github.com/NuWro/nuwro/archive/refs/tags/nuwro_19.02.2.tar.gz" git = "https://github.com/NuWro/nuwro" maintainers = [ # maintainer of this recipe, not affliated with the NuWro collaboration "davehadley" ] version( "19.2.2", sha256= "e6edf0cd3d9ae22261193ec9ee56f6a0bee5fbeae684f92361f091bb7f1fb055", ) version( "19.2.1", sha256= "66ec5ce8be747e821edf2e784fe579226c73301a886b0805410d929b61a90371", ) version( "19.2.0", sha256= "6b5dd5419fc43c3df9fc3c976180fffe24e48478502acdb86b4af8cc0f55e94f", ) version( "18.2.1", sha256= "4d3324207e1ff7192905b80dc0d422028ac06f1681c84430d8c33f6626a09c67", ) version( "18.2.0", sha256= "f98f5073ed3b1d21604ffd3ec1e2ca907a15aacd69c8e813526e3d2fd40b2ebc", ) version( "17.9.0", sha256= "350fa6043fa39253afad30bbcb655bde7d85b641843344aa978faca32535456d", ) version( "17.1.1", sha256= "5071d9d1495b780060215729bf7c52e1db0f26a213a1c25b5f7c99d43af97f65", ) version( "17.1.0", sha256= "bbbf73bc3c7436fb2fd28c7df538b4e20ad3f2f90a6c1c72f739f14a2ab8cf64", ) depends_on("root+pythia6") # nuwro does not actually require cmake, but root does. # Spack's concretizer fails with "unsatisfiable constraint" if we don't add this. depends_on("cmake@3:") # Missing include directive in nuwro2rootracker.cc causes compilation failure with # some versions of ROOT patch("nuwro2rootracker_missing_include.patch", level=0) def url_for_version(self, version): return ("https://github.com/NuWro/nuwro/archive/refs/tags/" "nuwro_{0}.{1:02d}.{2}.tar.gz".format(version[0], version[1], version[2])) @property def build_targets(self): return [ "CC=c++", "CXX=c++", "LD=c++", "FC=fc", "VERSION=%s" % self.spec.version, ] def install(self, spec, prefix): # nuwro has no install stage, # so we must install its binaries ourselves # install_tree function is injected into scope by spack build_environment.py install_tree("bin", prefix.bin) # noqa install_tree("data", os.sep.join((prefix, "data"))) # noqa def setup_run_environment(self, env): # nuwro uses this environment variable to find the data directory env.set("NUWRO", self.prefix) return super(Nuwro, self).setup_run_environment(env)