Skip to content
Snippets Groups Projects
Commit 2657119c authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

add steps to remove from global packages

parent 795802bf
No related branches found
No related tags found
1 merge request!82Remove cmd
......@@ -1148,8 +1148,25 @@ def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove
if package_set not in ["global_packages", "global"]:
remove_spack_environment(dir_to_remove / "spack", package_set)
else:
# TODO remove global packages by calling remove_spack_package
pass
# list all specs from the global_packages.list
spe_folder = root_dir / mpsd_release / "spack-environments"
package_list_file = (
spe_folder / "toolchains" / package_set / "global_packages.list"
)
with open(package_list_file, "r") as f:
package_dump = f.read()
# remove all content from # to the end of the line
package_dump = re.sub(r"#.*\n", "\n", package_dump)
# replace \\n with "" to remove line breaks
package_list = package_dump.replace("\\\n", "").split("\n")
# remove all empty lines
package_list = [line for line in package_list if line != ""]
# remove all packages in package_list
for package in package_list:
logging.info(f"Removing package {package} from installation")
remove_spack_package(dir_to_remove / "spack", package)
def remove_spack_environment(spack_dir, environment_name):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment