From 263666e292a8a4dcc06e89541618ea61a30eda15 Mon Sep 17 00:00:00 2001 From: chapman39 Date: Tue, 14 Oct 2025 16:09:23 -0700 Subject: [PATCH 1/3] keep builtin destination upon removing old builtin repo --- uberenv.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/uberenv.py b/uberenv.py index bc51323..27720a4 100755 --- a/uberenv.py +++ b/uberenv.py @@ -862,13 +862,6 @@ def clone_repo(self): if not os.path.exists(pjoin(self.dest_spack, "var", "spack", "repos", "builtin")): packages_repo = pjoin(self.dest_dir, "builtin_spack_packages_repo") - print(f"[info: moving spack builtin package repository to {packages_repo}]") - spack_repo_set_cmd = f"{self.spack_exe(use_spack_env=False)} repo set --destination {packages_repo} builtin" - res = sexe(spack_repo_set_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to set builtin package repository destination]") - sys.exit(-1) - # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag if "spack_packages_url" in self.project_args: spack_repo_remove_cmd = f"{self.spack_exe(use_spack_env=False)} repo remove builtin" @@ -885,6 +878,13 @@ def clone_repo(self): print("[ERROR: Failed to add builtin package repository with given URL]") sys.exit(-1) + print(f"[info: moving spack builtin package repository to {packages_repo}]") + spack_repo_set_cmd = f"{self.spack_exe(use_spack_env=False)} repo set --destination {packages_repo} builtin" + res = sexe(spack_repo_set_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to set builtin package repository destination]") + sys.exit(-1) + # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag if "spack_packages_commit" in self.project_args: sha1 = self.project_args["spack_packages_commit"] From 0bf5f75097e3e59ce1dd55c74665aa410b6b26e7 Mon Sep 17 00:00:00 2001 From: chapman39 Date: Tue, 14 Oct 2025 16:57:28 -0700 Subject: [PATCH 2/3] apply builtin repo in spack env --- uberenv.py | 109 +++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/uberenv.py b/uberenv.py index 00404cd..cc4a157 100755 --- a/uberenv.py +++ b/uberenv.py @@ -858,60 +858,6 @@ def clone_repo(self): print("[ERROR: Git failed to pull]") sys.exit(-1) - # Move and checkout Spack builtin package repository if not included in Spack repo - if not os.path.exists(pjoin(self.dest_spack, "var", "spack", "repos", "builtin")): - packages_repo = pjoin(self.dest_dir, "builtin_spack_packages_repo") - - # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag - if "spack_packages_url" in self.project_args: - spack_repo_remove_cmd = f"{self.spack_exe(use_spack_env=False)} repo remove builtin" - res = sexe(spack_repo_remove_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to remove builtin package repository so it could be re-added with given URL]") - sys.exit(-1) - - # Now add it back with the correct url - url = self.project_args["spack_packages_url"] - spack_repo_add_cmd = f"{self.spack_exe(use_spack_env=False)} repo add --name builtin {url}" - res = sexe(spack_repo_add_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to add builtin package repository with given URL]") - sys.exit(-1) - - print(f"[info: moving spack builtin package repository to {packages_repo}]") - spack_repo_set_cmd = f"{self.spack_exe(use_spack_env=False)} repo set --destination {packages_repo} builtin" - res = sexe(spack_repo_set_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to set builtin package repository destination]") - sys.exit(-1) - - # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag - if "spack_packages_commit" in self.project_args: - sha1 = self.project_args["spack_packages_commit"] - - spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --commit {sha1} builtin" - res = sexe(spack_repo_update_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to update git commit for builtin package repository]") - sys.exit(-1) - elif "spack_packages_branch" in self.project_args: - branch = self.project_args["spack_packages_branch"] - - spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --branch {branch} builtin" - res = sexe(spack_repo_update_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to update git branch for builtin package repository]") - sys.exit(-1) - elif "spack_packages_tag" in self.project_args: - tag = self.project_args["spack_packages_tag"] - - spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --tag {tag} builtin" - res = sexe(spack_repo_update_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to update git tag for builtin package repository]") - sys.exit(-1) - else: - print("[info: User did not specify any `spack_packages_*` override, Spack will pull the default ref of spack-packages]") def disable_spack_config_scopes(self): @@ -969,6 +915,61 @@ def create_spack_env(self): print("[ERROR: Failed to create Spack Environment]") sys.exit(-1) + # Move and checkout Spack builtin package repository if not included in Spack repo + if not os.path.exists(pjoin(self.dest_spack, "var", "spack", "repos", "builtin")): + packages_repo = pjoin(self.dest_dir, "builtin_spack_packages_repo") + + # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag + if "spack_packages_url" in self.project_args: + spack_repo_remove_cmd = f"{self.spack_exe()} repo remove builtin" + res = sexe(spack_repo_remove_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to remove builtin package repository so it could be re-added with given URL]") + sys.exit(-1) + + # Now add it back with the correct url + url = self.project_args["spack_packages_url"] + spack_repo_add_cmd = f"{self.spack_exe()} repo add --name builtin {url}" + res = sexe(spack_repo_add_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to add builtin package repository with given URL]") + sys.exit(-1) + + print(f"[info: moving spack builtin package repository to {packages_repo}]") + spack_repo_set_cmd = f"{self.spack_exe()} repo set --destination {packages_repo} builtin" + res = sexe(spack_repo_set_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to set builtin package repository destination]") + sys.exit(-1) + + # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag + if "spack_packages_commit" in self.project_args: + sha1 = self.project_args["spack_packages_commit"] + + spack_repo_update_cmd = f"{self.spack_exe()} repo update --commit {sha1} builtin" + res = sexe(spack_repo_update_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to update git commit for builtin package repository]") + sys.exit(-1) + elif "spack_packages_branch" in self.project_args: + branch = self.project_args["spack_packages_branch"] + + spack_repo_update_cmd = f"{self.spack_exe()} repo update --branch {branch} builtin" + res = sexe(spack_repo_update_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to update git branch for builtin package repository]") + sys.exit(-1) + elif "spack_packages_tag" in self.project_args: + tag = self.project_args["spack_packages_tag"] + + spack_repo_update_cmd = f"{self.spack_exe()} repo update --tag {tag} builtin" + res = sexe(spack_repo_update_cmd, echo=True) + if res != 0: + print("[ERROR: Failed to update git tag for builtin package repository]") + sys.exit(-1) + else: + print("[info: User did not specify any `spack_packages_*` override, Spack will pull the default ref of spack-packages]") + spack_pkg_keys = ("spack_packages_commit", "spack_packages_branch", "spack_packages_tag") if any(key in self.project_args for key in spack_pkg_keys): # Check if environment specifies alternate builtin packages repository From 7ab1bddefb59b3e8e7d707916da5f7abb830cee8 Mon Sep 17 00:00:00 2001 From: chapman39 Date: Tue, 14 Oct 2025 17:48:40 -0700 Subject: [PATCH 3/3] remove the remove --- uberenv.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/uberenv.py b/uberenv.py index cc4a157..48e72f9 100755 --- a/uberenv.py +++ b/uberenv.py @@ -859,7 +859,6 @@ def clone_repo(self): sys.exit(-1) - def disable_spack_config_scopes(self): # disables all config scopes except "defaults", which we will # force our settings into @@ -921,13 +920,6 @@ def create_spack_env(self): # Optionally, check out Spack's builtin package repo to a specific commit/branch/tag if "spack_packages_url" in self.project_args: - spack_repo_remove_cmd = f"{self.spack_exe()} repo remove builtin" - res = sexe(spack_repo_remove_cmd, echo=True) - if res != 0: - print("[ERROR: Failed to remove builtin package repository so it could be re-added with given URL]") - sys.exit(-1) - - # Now add it back with the correct url url = self.project_args["spack_packages_url"] spack_repo_add_cmd = f"{self.spack_exe()} repo add --name builtin {url}" res = sexe(spack_repo_add_cmd, echo=True)