Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some small issues with machine setup scripts #208

Merged
merged 3 commits into from
Apr 30, 2024
Merged
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
32 changes: 21 additions & 11 deletions machines/shared/add_dependencies_to_project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ elseif Sys.isapple()
MPIPreferences.use_system_binary()
catch
println("Failed to auto-detect path of MPI library...")

local mpi_library_path

default_mpi_library_path = get(mk_preferences, "mpi_library_path", "")
mpi_library_path = get_input_with_path_completion(
"\nEnter the full path to your MPI library (e.g. something like "
Expand All @@ -110,20 +113,27 @@ elseif Sys.isapple()
end

MPIPreferences.use_system_binary(library_names=mpi_library_path)
end

# Just got the value for the setting, now write it to LocalPreferences.toml
mk_preferences["mpi_library_path"] = mpi_library_path
open(local_preferences_filename, "w") do io
TOML.print(io, local_preferences, sorted=true)
global mk_preferences, local_preferences

# Just got the value for the setting, now write it to LocalPreferences.toml
mk_preferences["mpi_library_path"] = mpi_library_path
open(local_preferences_filename, "w") do io
TOML.print(io, local_preferences, sorted=true)
end
# Re-read local_preferences file, so we can modify it again below, keeping the
# changes here
local_preferences = TOML.parsefile(local_preferences_filename)
mk_preferences = local_preferences["moment_kinetics"]
end
# Re-read local_preferences file, so we can modify it again below, keeping the
# changes here
local_preferences = TOML.parsefile(local_preferences_filename)
mk_preferences = local_preferences["moment_kinetics"]
else
mpi_library_path = mk_preferences["mpi_library_path"]
MPIPreferences.use_system_binary(library_names=mpi_library_path)
if "mpi_library_path" ∈ keys(mk_preferences)
mpi_library_path = mk_preferences["mpi_library_path"]
MPIPreferences.use_system_binary(library_names=mpi_library_path)
else
# Must have auto-detected MPI library before, so do the same here
MPIPreferences.use_system_binary()
end
end
else
# If settings for MPI library are not given explicitly, then auto-detection by
Expand Down
9 changes: 8 additions & 1 deletion machines/shared/machine_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,15 @@ function machine_setup_moment_kinetics(machine::String; no_force_exit::Bool=fals
result = run(`grep "using Revise" $startup_path`, wait=false)
if !success(result)
println("Adding `using Revise` to $startup_path")
# When initialising a new copy of the repo, if Revise is not installed yet
# having just `using Revise` in the startup.jl would cause an error, so
# guard it with a try/catch.
open(startup_path, "a") do io
println(io, "\nusing Revise")
println(io, "\ntry")
println(io, " using Revise")
println(io, "catch")
println(io, " println(\"Warning: failed to load Revise\")")
println(io, "end")
end
end
end
Expand Down
Loading