Skip to content

Commit

Permalink
Merge pull request #63 from PumasAI/mh/custom-juliaup-channel-config
Browse files Browse the repository at this point in the history
Create custom `juliaup` channels during `install.jl`
  • Loading branch information
MichaelHatherly authored Dec 9, 2024
2 parents c0bb498 + 89718e5 commit 97669c4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/install.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,25 @@ function main()
for environment in readdir(environments)
path = joinpath(depot, "environments", environment)
if isdir(path)
package_bundler_toml = let file = joinpath(path, "PackageBundler.toml")
isfile(file) ? TOML.parsefile(file) : Dict{String,Any}()
end
juliaup_toml = get(Dict{String,Any}, package_bundler_toml, "juliaup")
custom_juliaup_channel = !isempty(juliaup_toml)
extra_args = get(juliaup_toml, "args", String[])
manifest_toml = TOML.parsefile(joinpath(path, "Manifest.toml"))
julia_version = manifest_toml["julia_version"]
push!(environment_worklist, (; path, environment, julia_version))
manifest_julia_version = manifest_toml["julia_version"]
julia_version = get(juliaup_toml, "channel", manifest_julia_version)
push!(
environment_worklist,
(;
path,
environment,
julia_version,
extra_args,
custom_juliaup_channel,
),
)
else
@warn "Environment not found" environment
end
Expand All @@ -179,6 +195,22 @@ function main()
@error "Failed to resolve and precompile environment" julia_version environment error
continue
end

if each.custom_juliaup_channel
juliaup_json = joinpath(dirname(dirname(Sys.BINDIR)), "juliaup.json")
if !isfile(juliaup_json)
@warn "Could not find `juliaup.json` config file. Skipping channel alias step."
else
file = @__FILE__
cmd = `juliaup link $(each.environment) $(file) -- $(channel) --project=$(environment) $(each.extra_args...)`
if !success(cmd)
@warn "failing to run juliaup linking, rerunning with output."
run(cmd)
end
juliaup_json_raw = read(juliaup_json, String)
write(juliaup_json, replace(juliaup_json_raw, file => "julia"))
end
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions src/remove.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function main()
else
@warn "Environment not found" environment
end
try
run(`juliaup remove $(environment)`)
catch error
@error "Failed to remove custom channel" environment error
end
end
Pkg.Registry.rm(Pkg.RegistrySpec(; uuid = "{{REGISTRY_UUID}}"))
end
Expand Down

0 comments on commit 97669c4

Please sign in to comment.