environment/view: small cleanup (#42395)

This commit is contained in:
Harmen Stoppels 2024-01-31 17:22:20 +01:00 committed by GitHub
parent f27bff81ba
commit 2bcfb72d38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View file

@ -680,8 +680,8 @@ def specs_for_view(self, concrete_roots: List[Spec]) -> List[Spec]:
with spack.store.STORE.db.read_transaction(): with spack.store.STORE.db.read_transaction():
return [s for s in specs if s in self and s.installed] return [s for s in specs if s in self and s.installed]
def regenerate(self, concretized_root_specs): def regenerate(self, concrete_roots: List[Spec]) -> None:
specs = self.specs_for_view(concretized_root_specs) specs = self.specs_for_view(concrete_roots)
# To ensure there are no conflicts with packages being installed # To ensure there are no conflicts with packages being installed
# that cannot be resolved or have repos that have been removed # that cannot be resolved or have repos that have been removed
@ -698,14 +698,14 @@ def regenerate(self, concretized_root_specs):
old_root = self._current_root old_root = self._current_root
if new_root == old_root: if new_root == old_root:
tty.debug("View at %s does not need regeneration." % self.root) tty.debug(f"View at {self.root} does not need regeneration.")
return return
_error_on_nonempty_view_dir(new_root) _error_on_nonempty_view_dir(new_root)
# construct view at new_root # construct view at new_root
if specs: if specs:
tty.msg("Updating view at {0}".format(self.root)) tty.msg(f"Updating view at {self.root}")
view = self.view(new=new_root) view = self.view(new=new_root)
@ -715,7 +715,7 @@ def regenerate(self, concretized_root_specs):
# Create a new view # Create a new view
try: try:
fs.mkdirp(new_root) fs.mkdirp(new_root)
view.add_specs(*specs, with_dependencies=False) view.add_specs(*specs)
# create symlink from tmp_symlink_name to new_root # create symlink from tmp_symlink_name to new_root
if os.path.exists(tmp_symlink_name): if os.path.exists(tmp_symlink_name):
@ -729,7 +729,7 @@ def regenerate(self, concretized_root_specs):
try: try:
shutil.rmtree(new_root, ignore_errors=True) shutil.rmtree(new_root, ignore_errors=True)
os.unlink(tmp_symlink_name) os.unlink(tmp_symlink_name)
except (IOError, OSError): except OSError:
pass pass
# Give an informative error message for the typical error case: two specs, same package # Give an informative error message for the typical error case: two specs, same package

View file

@ -666,9 +666,6 @@ def add_specs(self, *specs, **kwargs):
tty.warn("Skipping external package: " + s.short_spec) tty.warn("Skipping external package: " + s.short_spec)
specs = [s for s in specs if not s.external] specs = [s for s in specs if not s.external]
if kwargs.get("exclude", None):
specs = set(filter_exclude(specs, kwargs["exclude"]))
self._sanity_check_view_projection(specs) self._sanity_check_view_projection(specs)
# Ignore spack meta data folder. # Ignore spack meta data folder.