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

Create custom juliaup channels during install.jl #63

Merged
merged 1 commit into from
Dec 9, 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
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
Loading