Esempio n. 1
0
    def _update_provider_index(self):
        # Check modification dates of all packages
        self._fast_package_check()

        def read():
            with open(self.index_file) as f:
                self._provider_index = ProviderIndex.from_yaml(f)

        # Read the old ProviderIndex, or make a new one.
        key = self._cache_file
        index_existed = spack.misc_cache.init_entry(key)
        if index_existed and not self._needs_update:
            with spack.misc_cache.read_transaction(key) as f:
                self._provider_index = ProviderIndex.from_yaml(f)
        else:
            with spack.misc_cache.write_transaction(key) as (old, new):
                if old:
                    self._provider_index = ProviderIndex.from_yaml(old)
                else:
                    self._provider_index = ProviderIndex()

                for pkg_name in self._needs_update:
                    namespaced_name = '%s.%s' % (self.namespace, pkg_name)
                    self._provider_index.remove_provider(namespaced_name)
                    self._provider_index.update(namespaced_name)

                self._provider_index.to_yaml(new)
Esempio n. 2
0
File: repo.py Progetto: zygyz/spack
    def provider_index(self):
        """Merged ProviderIndex from all Repos in the RepoPath."""
        if self._provider_index is None:
            self._provider_index = ProviderIndex()
            for repo in reversed(self.repos):
                self._provider_index.merge(repo.provider_index)

        return self._provider_index
Esempio n. 3
0
def test_yaml_round_trip(mock_packages):
    p = ProviderIndex(spack.repo.all_package_names())

    ostream = StringIO()
    p.to_yaml(ostream)

    istream = StringIO(ostream.getvalue())
    q = ProviderIndex.from_yaml(istream)

    assert p == q
Esempio n. 4
0
    def test_yaml_round_trip(self):
        p = ProviderIndex(spack.repo.all_package_names())

        ostream = StringIO()
        p.to_yaml(ostream)

        istream = StringIO(ostream.getvalue())
        q = ProviderIndex.from_yaml(istream)

        self.assertEqual(p, q)
Esempio n. 5
0
def test_mpi_providers(mock_packages):
    p = ProviderIndex(spack.repo.all_package_names())

    mpi_2_providers = p.providers_for('mpi@2')
    assert Spec('mpich2') in mpi_2_providers
    assert Spec('mpich@3:') in mpi_2_providers

    mpi_3_providers = p.providers_for('mpi@3')
    assert Spec('mpich2') not in mpi_3_providers
    assert Spec('mpich@3:') in mpi_3_providers
    assert Spec('zmpi') in mpi_3_providers
Esempio n. 6
0
def test_providers_for_simple(mock_packages):
    p = ProviderIndex(spack.repo.all_package_names())

    blas_providers = p.providers_for('blas')
    assert Spec('netlib-blas') in blas_providers
    assert Spec('openblas') in blas_providers
    assert Spec('openblas-with-lapack') in blas_providers

    lapack_providers = p.providers_for('lapack')
    assert Spec('netlib-lapack') in lapack_providers
    assert Spec('openblas-with-lapack') in lapack_providers
Esempio n. 7
0
    def test_mpi_providers(self):
        p = ProviderIndex(spack.repo.all_package_names())

        mpi_2_providers = p.providers_for('mpi@2')
        self.assertTrue(Spec('mpich2') in mpi_2_providers)
        self.assertTrue(Spec('mpich@3:') in mpi_2_providers)

        mpi_3_providers = p.providers_for('mpi@3')
        self.assertTrue(Spec('mpich2') not in mpi_3_providers)
        self.assertTrue(Spec('mpich@3:') in mpi_3_providers)
        self.assertTrue(Spec('zmpi') in mpi_3_providers)
Esempio n. 8
0
    def test_providers_for_simple(self):
        p = ProviderIndex(spack.repo.all_package_names())

        blas_providers = p.providers_for('blas')
        self.assertTrue(Spec('netlib-blas') in blas_providers)
        self.assertTrue(Spec('openblas') in blas_providers)
        self.assertTrue(Spec('openblas-with-lapack') in blas_providers)

        lapack_providers = p.providers_for('lapack')
        self.assertTrue(Spec('netlib-lapack') in lapack_providers)
        self.assertTrue(Spec('openblas-with-lapack') in lapack_providers)
Esempio n. 9
0
File: repo.py Progetto: zygyz/spack
def make_provider_index_cache(packages_path, namespace):
    """Lazily updates the provider index cache associated with a repository,
    if need be, then returns it. Caches results for later look-ups.

    Args:
        packages_path: path of the repository
        namespace: namespace of the repository

    Returns:
        instance of ProviderIndex
    """
    # Map that goes from package names to stat info
    fast_package_checker = FastPackageChecker(packages_path)

    # Filename of the provider index cache
    cache_filename = 'providers/{0}-index.yaml'.format(namespace)

    # Compute which packages needs to be updated in the cache
    misc_cache = spack.caches.misc_cache
    index_mtime = misc_cache.mtime(cache_filename)

    needs_update = [
        x for x, sinfo in fast_package_checker.items()
        if sinfo.st_mtime > index_mtime
    ]

    # Read the old ProviderIndex, or make a new one.
    index_existed = misc_cache.init_entry(cache_filename)

    if index_existed and not needs_update:

        # If the provider index exists and doesn't need an update
        # just read from it
        with misc_cache.read_transaction(cache_filename) as f:
            index = ProviderIndex.from_yaml(f)

    else:

        # Otherwise we need a write transaction to update it
        with misc_cache.write_transaction(cache_filename) as (old, new):

            index = ProviderIndex.from_yaml(old) if old else ProviderIndex()

            for pkg_name in needs_update:
                namespaced_name = '{0}.{1}'.format(namespace, pkg_name)
                index.remove_provider(namespaced_name)
                index.update(namespaced_name)

            index.to_yaml(new)

    return index
Esempio n. 10
0
def test_copy(mock_packages):
    p = ProviderIndex(spack.repo.all_package_names())
    q = p.copy()
    assert p == q
Esempio n. 11
0
def test_equal(mock_packages):
    p = ProviderIndex(spack.repo.all_package_names())
    q = ProviderIndex(spack.repo.all_package_names())
    assert p == q
Esempio n. 12
0
 def _create(self):
     return ProviderIndex()
Esempio n. 13
0
def test_copy(builtin_mock):
    p = ProviderIndex(spack.repo.all_package_names())
    q = p.copy()
    assert p == q
Esempio n. 14
0
def test_equal(builtin_mock):
    p = ProviderIndex(spack.repo.all_package_names())
    q = ProviderIndex(spack.repo.all_package_names())
    assert p == q
Esempio n. 15
0
 def test_copy(self):
     p = ProviderIndex(spack.repo.all_package_names())
     q = p.copy()
     self.assertEqual(p, q)