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

use . instead of source to be POSIX compliant

parent 79fcc02b
Branches
No related tags found
1 merge request!82Remove cmd
...@@ -1079,17 +1079,41 @@ def install_environment( ...@@ -1079,17 +1079,41 @@ def install_environment(
def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove=False): def remove_environment(mpsd_release, root_dir, package_sets="NONE", force_remove=False):
"""Remove release from installation.""" """Remove release from installation.
Handle 3 situations :
1. remove dosent specify what to remove
-> warn and exit
2. remove all package_sets from release
-> remove release folder except logs
3. remove specific package_sets from release
-> remove spack environments via spack commands
Parameters
----------
mpsd_release : str
A string representing the MPSD release version.
root_dir : pathlib.Path
A Path object representing the path to the directory where
the release and package_sets will be installed.
package_sets : list of str
A list of strings representing the package_sets to install
(e.g., "foss2021a-mpi", "global_generic", "ALL").
force_remove : bool, optional
A boolean indicating whether to force remove the release.
If False, the user will be prompted to confirm the removal.
Defaults to False.
Raises
------
ValueError
"""
msg = ( msg = (
f"Removing release {mpsd_release}" f"Removing release {mpsd_release}"
f" with package_sets {package_sets} from {root_dir}" f" with package_sets {package_sets} from {root_dir}"
) )
logging.warning(msg) logging.warning(msg)
# Handle 3 situations :
# 1. remove dosent specify what to remove -> warn and exit
# 2. remove all package_sets from release -> remove release folder except logs
# 3. remove specific package_sets from release
# -> remove spack environments via spack commands
if package_sets == "NONE": if package_sets == "NONE":
logging.warning( logging.warning(
...@@ -1133,7 +1157,8 @@ def remove_spack_environment(spack_dir, environment_name): ...@@ -1133,7 +1157,8 @@ def remove_spack_environment(spack_dir, environment_name):
logging.warning(f"Removing spack environment {environment_name}") logging.warning(f"Removing spack environment {environment_name}")
spack_env = spack_dir / "share" / "spack" / "setup-env.sh" spack_env = spack_dir / "share" / "spack" / "setup-env.sh"
commands_to_execute = [ commands_to_execute = [
f"source {spack_env}", f"export SPACK_DIR={spack_dir}",
f". {spack_env}",
f"spack env activate {environment_name}", f"spack env activate {environment_name}",
f"for spec in $(spack -e {environment_name} find" # this line continues f"for spec in $(spack -e {environment_name} find" # this line continues
r' --format "{name}@{version}%{compiler.name}@{compiler.version}");do' r' --format "{name}@{version}%{compiler.name}@{compiler.version}");do'
......
...@@ -778,7 +778,8 @@ def test_remove_package_sets(tmp_path, simple_toolchain): ...@@ -778,7 +778,8 @@ def test_remove_package_sets(tmp_path, simple_toolchain):
# check that zlib@1.2 is still installed # check that zlib@1.2 is still installed
# spack location -i <package> exit 0 if installed and 1 if not installed # spack location -i <package> exit 0 if installed and 1 if not installed
source_spack = ( source_spack = (
f'source {release_dir / "spack" / "share" / "spack" / "setup-env.sh"}' f"export SPACK_DIR={release_dir} &&"
f'. {release_dir / "spack" / "share" / "spack" / "setup-env.sh"}'
) )
mod.run(f"{source_spack} && spack location -i zlib", shell=True, check=True) mod.run(f"{source_spack} && spack location -i zlib", shell=True, check=True)
# check that zstd@1.5 is not installed # check that zstd@1.5 is not installed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment