-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5978de2
commit c301851
Showing
3 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,5 +289,6 @@ end | |
|
||
include("openssl.jl") | ||
include("code_stripping.jl") | ||
include("utilities.jl") | ||
|
||
end # module PackageBundler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
""" | ||
instantiate(environments::String) | ||
Scan the directory `environments` for subdirectories containing a | ||
`Manifest.toml` file and instantiate them all using the appropriate `julia` | ||
version as specified in the `Manifest.toml` file. This uses either `juliaup` or | ||
`asdf` to switch between `julia` versions as needed. Make sure to have either of | ||
those installed, as well as the expected `julia` versions. | ||
""" | ||
function instantiate(environments::String) | ||
if ispath(environments) | ||
if isfile(environments) | ||
error("The path '$environments' is a file, not a directory.") | ||
end | ||
else | ||
error("The path '$environments' does not exist.") | ||
end | ||
for each in readdir(environments; join = true) | ||
manifest = joinpath(each, "Manifest.toml") | ||
if isfile(manifest) | ||
@info "Instantiating $each" | ||
toml = TOML.parsefile(manifest) | ||
julia_version = toml["julia_version"] | ||
if !isnothing(Sys.which("juliaup")) | ||
@info "Checking whether Julia '$julia_version' is installed, if not, installing it." | ||
run(`juliaup add $julia_version`) | ||
withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do | ||
run( | ||
`julia +$(julia_version) --project=$each -e 'import Pkg; Pkg.instantiate()'`, | ||
) | ||
end | ||
elseif !isnothing(Sys.which("asdf")) | ||
# Using the `ASDF_JULIA_VERSION` environment variable to control the | ||
# `julia` version used doesn't appear to have an effect. Instead | ||
# compute the exact path to the binary and use that instead. | ||
asdf_dir = get( | ||
ENV, | ||
"ASDF_DATA_DIR", | ||
get(ENV, "ASDF_DIR", joinpath(homedir(), ".asdf")), | ||
) | ||
if isdir(asdf_dir) | ||
julia_path = joinpath( | ||
asdf_dir, | ||
"installs", | ||
"julia", | ||
"$(julia_version)", | ||
"bin", | ||
"julia", | ||
) | ||
if !isfile(julia_path) | ||
@info "Installing Julia '$julia_version', since it does not appear to be installed." | ||
run(`asdf install julia $julia_version`) | ||
end | ||
if isfile(julia_path) | ||
withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do | ||
run( | ||
`$julia_path --project=$each -e 'import Pkg; Pkg.instantiate()'`, | ||
) | ||
end | ||
else | ||
error( | ||
"The `julia` binary for version $julia_version failed to install.", | ||
) | ||
end | ||
else | ||
error("`asdf` is not installed in a known location. $asdf_dir") | ||
end | ||
else | ||
error("`asdf` or `juliaup` is required to instantiate the environments.") | ||
end | ||
end | ||
end | ||
end |