Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions mpd/concretize.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ def cmake_develop(project_config, package_cmake_args):
out.write(
f"""set(CWD "{file_dir}")
macro(develop pkg)
install(CODE "execute_process(COMMAND spack python ensure-install-directory.py\\
{project_name} ${{${{pkg}}_HASH}}\\
WORKING_DIRECTORY ${{CWD}})")
set(CMAKE_INSTALL_PREFIX ${{${{pkg}}_INSTALL_PREFIX}})
string(REPLACE "-" "_" pkg_with_underscores ${{pkg}})
string(TOLOWER "${{pkg_with_underscores}}" pkg_with_underscores)
Expand All @@ -131,9 +128,6 @@ def cmake_develop(project_config, package_cmake_args):
if (COMMAND unset_${{pkg_with_underscores}}_variables)
cmake_language(CALL "unset_${{pkg_with_underscores}}_variables")
endif()
install(CODE "execute_process(COMMAND spack python add-to-database.py\\
{project_name} ${{${{pkg}}_HASH}}\\
WORKING_DIRECTORY ${{CWD}})")
endmacro()
"""
)
Expand Down
49 changes: 40 additions & 9 deletions mpd/install.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import subprocess
from datetime import datetime
from pathlib import Path
import json

import spack.environment as ev

Expand All @@ -26,24 +28,53 @@ def process(args):

project_config = selected_project_config()
activate_development_environment(project_config["local"])
project_name = project_config["name"]
file_dir = Path(__file__).resolve().parent
stdout = None if args.verbose else subprocess.DEVNULL

all_arguments = ["cmake", "--install", project_config["build"]]
all_arguments_str = " ".join(all_arguments)
packages = [p for p in project_config["packages"]]

print()
tty.msg("Installing developed packages with command:\n\n" + cyan(all_arguments_str) + "\n")
presets = {}
source_path = Path(project_config["source"])
with open((source_path / "CMakePresets.json").absolute(), "r") as f:
presets = json.load(f)
preset_obj = presets["configurePresets"][0]["cacheVariables"]

stdout = None if args.verbose else subprocess.DEVNULL
subprocess.run(all_arguments, stdout=stdout)
# sanity check: make sure all packages have been built
for pkg in packages:
if not Path(project_config["build"] + "/" + pkg + "/cmake_install.cmake").exists():
tty.error(f"Package {pkg} has not been built yet. Please run 'spack mpd build' first.")
return

# Make sure install directories are created so add-to-database doesn't complain
for pkg in packages:
if preset_obj[pkg + "_HASH"] is not None:
all_arguments = ["spack", "python", "ensure-install-directory.py", project_name, preset_obj[pkg + "_HASH"]]
subprocess.run(all_arguments, stdout=stdout, cwd = file_dir)

for pkg in packages:
all_arguments = ["cmake", "--install", project_config["build"] + "/" + pkg]
if preset_obj[pkg + "_INSTALL_PREFIX"] is not None:
all_arguments.append("--prefix")
all_arguments.append(preset_obj[pkg + "_INSTALL_PREFIX"])
all_arguments_str = " ".join(all_arguments)

print()
tty.msg(f"Installing {pkg} with command:\n\n" + cyan(all_arguments_str) + "\n")

subprocess.run(all_arguments, stdout=stdout)

if preset_obj[pkg + "_HASH"] is not None:
all_arguments = ["spack", "python", "add-to-database.py", project_name, preset_obj[pkg + "_HASH"]]
subprocess.run(all_arguments, stdout=stdout, cwd = file_dir)

tty.msg(gray("Installing environment"))
# Now install the environment
name = project_config["name"]
env = ev.read(name)
env = ev.read(project_name)
with env, env.write_transaction():
env.install_all()
env.write()

update(project_config, installed_at=datetime.now().replace(microsecond=0).isoformat(" "))
print()
tty.msg(f"The {bold(name)} environment has been installed.\n")
tty.msg(f"The {bold(project_name)} environment has been installed.\n")