Exemplo n.º 1
0
def test_report():
    out = debug('report')
    arch = architecture.Arch(architecture.platform(), 'frontend', 'frontend')

    assert get_version() in out
    assert platform.python_version() in out
    assert str(arch) in out
    assert spack.config.get('config:concretizer') in out
Exemplo n.º 2
0
def test_get_version_bad_git(tmpdir, working_env):
    bad_git = str(tmpdir.join("git"))
    with open(bad_git, "w") as f:
        f.write("""#!/bin/sh
exit 1
""")
    fs.set_executable(bad_git)

    os.environ["PATH"] = str(tmpdir)
    assert spack.spack_version == get_version()
Exemplo n.º 3
0
def test_get_version_match_git(tmpdir, working_env):
    git = str(tmpdir.join("git"))
    with open(git, "w") as f:
        f.write("""#!/bin/sh
echo v0.13.3-912-g3519a1762
""")
    fs.set_executable(git)

    os.environ["PATH"] = str(tmpdir)
    assert "0.13.3-912-3519a1762" == get_version()
Exemplo n.º 4
0
def test_get_version_no_match_git(tmpdir, working_env):
    git = str(tmpdir.join("git"))
    with open(git, "w") as f:
        f.write("""#!/bin/sh
echo v0.13.3
""")
    fs.set_executable(git)

    os.environ["PATH"] = str(tmpdir)
    assert spack.spack_version == get_version()
Exemplo n.º 5
0
def test_version_git_nonsense_output(tmpdir, working_env):
    git = str(tmpdir.join("git"))
    with open(git, "w") as f:
        f.write("""#!/bin/sh
echo --|not a hash|----
""")
    fs.set_executable(git)

    os.environ["PATH"] = str(tmpdir)
    assert spack.spack_version == get_version()
Exemplo n.º 6
0
def test_version_git_fails(tmpdir, working_env):
    git = str(tmpdir.join("git"))
    with open(git, "w") as f:
        f.write("""#!/bin/sh
echo 26552533be04e83e66be2c28e0eb5011cb54e8fa
exit 1
""")
    fs.set_executable(git)

    os.environ["PATH"] = str(tmpdir)
    assert spack.spack_version == get_version()
Exemplo n.º 7
0
def report(args):
    host_platform = spack.platforms.host()
    host_os = host_platform.operating_system('frontend')
    host_target = host_platform.target('frontend')
    architecture = spack.spec.ArchSpec(
        (str(host_platform), str(host_os), str(host_target))
    )
    print('* **Spack:**', get_version())
    print('* **Python:**', platform.python_version())
    print('* **Platform:**', architecture)
    print('* **Concretizer:**', spack.config.get('config:concretizer'))
Exemplo n.º 8
0
def test_git_sha_output(tmpdir, working_env):
    git = str(tmpdir.join("git"))
    sha = '26552533be04e83e66be2c28e0eb5011cb54e8fa'
    with open(git, "w") as f:
        f.write("""#!/bin/sh
echo {0}
""".format(sha))
    fs.set_executable(git)

    os.environ["PATH"] = str(tmpdir)
    expected = "{0} ({1})".format(spack.spack_version, sha)
    assert expected == get_version()
Exemplo n.º 9
0
def test_report():
    out = debug('report')
    host_platform = spack.platforms.host()
    host_os = host_platform.operating_system('frontend')
    host_target = host_platform.target('frontend')
    architecture = spack.spec.ArchSpec(
        (str(host_platform), str(host_os), str(host_target)))

    assert get_version() in out
    assert platform.python_version() in out
    assert str(architecture) in out
    assert spack.config.get('config:concretizer') in out
Exemplo n.º 10
0
 def install(self, spec, prefix):
     """ Create bash setup script in prefix."""
     # first, log spack version to build-out
     tty.msg('* **Spack:**', get_version())
     tty.msg('* **Python:**', platform.python_version())
     tty.msg(
         '* **Platform:**',
         architecture.Arch(architecture.platform(), 'frontend', 'frontend'))
     # get all dependency specs, including compiler
     with spack.store.db.read_transaction():
         specs = [dep for dep in spec.traverse(order='post')]
     # record all changes to the environment by packages in the stack
     env_mod = spack.util.environment.EnvironmentModifications()
     # first setup compiler, similar to build_environment.py in spack
     compiler = self.compiler
     if compiler.cc:
         env_mod.set('CC', compiler.cc)
     if compiler.cxx:
         env_mod.set('CXX', compiler.cxx)
     if compiler.f77:
         env_mod.set('F77', compiler.f77)
     if compiler.fc:
         env_mod.set('FC', compiler.fc)
     compiler.setup_custom_environment(self, env_mod)
     env_mod.prepend_path('PATH', os.path.dirname(compiler.cxx))
     # now setup all other packages
     for _spec in specs:
         env_mod.extend(uenv.environment_modifications_for_spec(_spec))
         env_mod.prepend_path(uenv.spack_loaded_hashes_var,
                              _spec.dag_hash())
     # transform to bash commands, and write to file
     cmds = k4_generate_setup_script(env_mod)
     with open(os.path.join(prefix, "setup.sh"), "w") as f:
         f.write(cmds)
         # optionally add a symlink (location configurable via environment variable
         # K4_LATEST_SETUP_PATH. Step will be skipped if it is empty)
         try:
             symlink_path = os.environ.get("K4_LATEST_SETUP_PATH", "")
             if symlink_path:
                 # make sure that the path exists, create if not
                 if not os.path.exists(os.path.dirname(symlink_path)):
                     os.makedirs(os.path.dirname(symlink_path))
                 # make sure that an existing file will be overwritten,
                 # even if it is a symlink (for which 'exists' is false!)
                 if os.path.exists(symlink_path) or os.path.islink(
                         symlink_path):
                     os.remove(symlink_path)
                 os.symlink(os.path.join(prefix, "setup.sh"), symlink_path)
         except:
             tty.warn("Could not create symlink")
Exemplo n.º 11
0
 def install(self, spec, prefix):
     """ Create bash setup script in prefix."""
     # first, log spack version to build-out
     tty.msg('* **Spack:**', get_version())
     tty.msg('* **Python:**', platform.python_version())
     tty.msg(
         '* **Platform:**',
         architecture.Arch(architecture.platform(), 'frontend', 'frontend'))
     # get all dependency specs, including compiler
     with spack.store.db.read_transaction():
         specs = [dep for dep in spec.traverse(order='post')]
         try:
             gcc_spec = spack.cmd.disambiguate_spec(str(spec.compiler),
                                                    None,
                                                    first=True)
             gcc_specs = [dep for dep in gcc_spec.traverse(order='post')]
             specs = specs + gcc_specs
         except:
             tty.warn("No spec found for " + str(spec.compiler) +
                      ". Assuming it is a system compiler,"
                      "not adding it to the setup.")
     # record all changes to the environment by packages in the stack
     env_mod = spack.util.environment.EnvironmentModifications()
     for _spec in specs:
         env_mod.extend(uenv.environment_modifications_for_spec(_spec))
         env_mod.prepend_path(uenv.spack_loaded_hashes_var,
                              _spec.dag_hash())
     # transform to bash commands, and write to file
     cmds = k4_generate_setup_script(env_mod)
     with open(os.path.join(prefix, "setup.sh"), "w") as f:
         f.write(cmds)
         # optionally add a symlink (location configurable via environment variable
         # K4_LATEST_SETUP_PATH. Step will be skipped if it is empty)
         try:
             symlink_path = os.environ.get("K4_LATEST_SETUP_PATH", "")
             if symlink_path:
                 # make sure that the path exists, create if not
                 if not os.path.exists(os.path.dirname(symlink_path)):
                     os.makedirs(os.path.dirname(symlink_path))
                 # make sure that an existing file will be overwritten,
                 # even if it is a symlink (for which 'exists' is false!)
                 if os.path.exists(symlink_path) or os.path.islink(
                         symlink_path):
                     os.remove(symlink_path)
                 os.symlink(os.path.join(prefix, "setup.sh"), symlink_path)
         except:
             tty.warn("Could not create symlink")
Exemplo n.º 12
0
    def install(self, spec, prefix):
      """ Create bash setup script in prefix."""

      # first, log spack version to build-out

      tty.msg('* **Spack:**', get_version())
      tty.msg('* **Python:**', platform.python_version())
      tty.msg('* **Platform:**', architecture.Arch(
          architecture.platform(), 'frontend', 'frontend'))


      specs = [spec]
      with spack.store.db.read_transaction():
               specs = [dep for _spec in specs
                        for dep in
                        _spec.traverse( order='post')]
               try: 
                   gcc_specs = [spack.cmd.disambiguate_spec(str(spec.compiler), None, first=True)]
                   gcc_specs = [dep for _spec in gcc_specs
                            for dep in
                            _spec.traverse( order='post')]
                   specs = specs + gcc_specs
               except:
                   tty.warn("No spec found for " + str(spec.compiler) + " Assuming it is a system compiler and not adding it to the setup.")
      env_mod = spack.util.environment.EnvironmentModifications()
      for _spec in specs:
          env_mod.extend(uenv.environment_modifications_for_spec(_spec))
          env_mod.prepend_path(uenv.spack_loaded_hashes_var, _spec.dag_hash())
      cmds = k4_generate_setup_script(env_mod)
      with open(os.path.join(prefix, "setup.sh"), "w") as f:
        f.write(cmds)
        try:
          symlink_path = os.environ.get("K4_LATEST_SETUP_PATH", "")
          if symlink_path:
              if not os.path.exists(os.path.dirname(symlink_path)):
                os.makedirs(os.path.dirname(symlink_path))
              if os.path.exists(symlink_path) or os.path.islink(symlink_path):
                os.remove(symlink_path)
              os.symlink(os.path.join(prefix, "setup.sh"), symlink_path)
        except:
          tty.warn("Could not create symlink")
Exemplo n.º 13
0
def test_get_version_no_git(tmpdir, working_env):
    os.environ["PATH"] = str(tmpdir)
    assert spack.spack_version == get_version()
Exemplo n.º 14
0
def test_get_version_no_repo(tmpdir, monkeypatch):
    monkeypatch.setattr(spack.paths, "prefix", str(tmpdir))
    assert spack.spack_version == get_version()
Exemplo n.º 15
0
def report(args):
    print('* **Spack:**', get_version())
    print('* **Python:**', platform.python_version())
    print('* **Platform:**',
          architecture.Arch(architecture.platform(), 'frontend', 'frontend'))
Exemplo n.º 16
0
def report(args):
    print('* **Spack:**', get_version())
    print('* **Python:**', platform.python_version())
    print('* **Platform:**', architecture.Arch(
        architecture.platform(), 'frontend', 'frontend'))
    print('* **Concretizer:**', spack.config.get('config:concretizer'))