Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
cf2f902b
Commit
cf2f902b
authored
8 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Make ProviderIndexes mergeable, so we can cache them per-repo.
parent
bf028990
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/spack/spack/repository.py
+23
-8
23 additions, 8 deletions
lib/spack/spack/repository.py
lib/spack/spack/test/virtual.py
+6
-0
6 additions, 0 deletions
lib/spack/spack/test/virtual.py
lib/spack/spack/virtual.py
+28
-0
28 additions, 0 deletions
lib/spack/spack/virtual.py
with
57 additions
and
8 deletions
lib/spack/spack/repository.py
+
23
−
8
View file @
cf2f902b
...
@@ -224,12 +224,20 @@ def all_packages(self):
...
@@ -224,12 +224,20 @@ def all_packages(self):
yield
self
.
get
(
name
)
yield
self
.
get
(
name
)
@_autospec
@property
def
providers_for
(
self
,
vpkg_spec
):
def
provider_index
(
self
):
"""
Merged ProviderIndex from all Repos in the RepoPath.
"""
if
self
.
_provider_index
is
None
:
if
self
.
_provider_index
is
None
:
self
.
_provider_index
=
ProviderIndex
(
self
.
all_package_names
())
self
.
_provider_index
=
ProviderIndex
()
for
repo
in
reversed
(
self
.
repos
):
self
.
_provider_index
.
merge
(
repo
.
provider_index
)
return
self
.
_provider_index
providers
=
self
.
_provider_index
.
providers_for
(
vpkg_spec
)
@_autospec
def
providers_for
(
self
,
vpkg_spec
):
providers
=
self
.
provider_index
.
providers_for
(
vpkg_spec
)
if
not
providers
:
if
not
providers
:
raise
UnknownPackageError
(
vpkg_spec
.
name
)
raise
UnknownPackageError
(
vpkg_spec
.
name
)
return
providers
return
providers
...
@@ -603,12 +611,19 @@ def purge(self):
...
@@ -603,12 +611,19 @@ def purge(self):
self
.
_instances
.
clear
()
self
.
_instances
.
clear
()
@_autospec
@property
def
providers_for
(
self
,
vpkg_spec
):
def
provider_index
(
self
):
"""
A provider index with names *specific* to this repo.
"""
if
self
.
_provider_index
is
None
:
if
self
.
_provider_index
is
None
:
self
.
_provider_index
=
ProviderIndex
(
self
.
all_package_names
())
namespaced_names
=
[
'
%s.%s
'
%
(
self
.
namespace
,
n
)
for
n
in
self
.
all_package_names
()]
self
.
_provider_index
=
ProviderIndex
(
namespaced_names
)
return
self
.
_provider_index
providers
=
self
.
_provider_index
.
providers_for
(
vpkg_spec
)
@_autospec
def
providers_for
(
self
,
vpkg_spec
):
providers
=
self
.
provider_index
.
providers_for
(
vpkg_spec
)
if
not
providers
:
if
not
providers
:
raise
UnknownPackageError
(
vpkg_spec
.
name
)
raise
UnknownPackageError
(
vpkg_spec
.
name
)
return
providers
return
providers
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/test/virtual.py
+
6
−
0
View file @
cf2f902b
...
@@ -41,3 +41,9 @@ def test_write_and_read(self):
...
@@ -41,3 +41,9 @@ def test_write_and_read(self):
q
=
ProviderIndex
.
from_yaml
(
istream
)
q
=
ProviderIndex
.
from_yaml
(
istream
)
self
.
assertTrue
(
p
==
q
)
self
.
assertTrue
(
p
==
q
)
def
test_copy
(
self
):
p
=
ProviderIndex
(
spack
.
repo
.
all_package_names
())
q
=
p
.
copy
()
self
.
assertTrue
(
p
==
q
)
This diff is collapsed.
Click to expand it.
lib/spack/spack/virtual.py
+
28
−
0
View file @
cf2f902b
...
@@ -209,5 +209,33 @@ def from_yaml(stream):
...
@@ -209,5 +209,33 @@ def from_yaml(stream):
return
index
return
index
def
merge
(
self
,
other
):
"""
Merge `other` ProviderIndex into this one.
"""
other
=
other
.
copy
()
# defensive copy.
for
pkg
in
other
.
providers
:
if
pkg
not
in
self
.
providers
:
self
.
providers
[
pkg
]
=
other
.
providers
[
pkg
]
continue
spdict
,
opdict
=
self
.
providers
[
pkg
],
other
.
providers
[
pkg
]
for
provided_spec
in
opdict
:
if
provided_spec
not
in
spdict
:
spdict
[
provided_spec
]
=
opdict
[
provided_spec
]
continue
spdict
[
provided_spec
]
+=
opdict
[
provided_spec
]
def
copy
(
self
):
"""
Deep copy of this ProviderIndex.
"""
clone
=
ProviderIndex
()
clone
.
providers
=
dict
(
(
name
,
dict
((
vpkg
,
set
((
p
.
copy
()
for
p
in
pset
)))
for
vpkg
,
pset
in
pdict
.
items
()))
for
name
,
pdict
in
self
.
providers
.
items
())
return
clone
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
return
self
.
providers
==
other
.
providers
return
self
.
providers
==
other
.
providers
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment