Skip to content

Commit

Permalink
Merge pull request #208 from mabarnes/machine-setup-fixes
Browse files Browse the repository at this point in the history
Fix some small issues with machine setup scripts
  • Loading branch information
johnomotani authored Apr 30, 2024
2 parents b860d61 + e6379a2 commit 1ef9209
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
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

0 comments on commit 1ef9209

Please sign in to comment.