Skip to content

Commit

Permalink
Check if CONDA_JL_CONDA_EXE exists & executable. Install only in ROOTENV
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Jan 15, 2022
1 parent c95e1ab commit 8eb7c9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 9 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@ if haskey(ENV, "CONDA_JL_CONDA_EXE")
if uperm(CONDA_EXE) & 0x01 > 0
@info "Executable conda located." CONDA_EXE
else
error("$CONDA_EXE cannot be executed by the current user.")
error("CONDA_JL_CONDA_EXE, $CONDA_EXE, cannot be executed by the current user.")
end
else
error("$CONDA_EXE does not exist.")
error("CONDA_JL_CONDA_EXE, $CONDA_EXE, does not exist.")
end
else
if !isfile(CONDA_EXE)
# An old CONDA_EXE has gone missing, revert to default in ROOTENV
@info "CONDA_EXE not found. Reverting to default in ROOTENV" CONDA_EXE ROOTENV
CONDA_EXE = DefaultDeps.default_conda_exe(ROOTENV)
end
end


deps = """
const ROOTENV = "$(escape_string(ROOTENV))"
const MINICONDA_VERSION = "$(escape_string(MINICONDA_VERSION))"
Expand Down
13 changes: 5 additions & 8 deletions src/Conda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,21 @@ _quiet() = get(ENV, "CI", "false") == "true" ? `-q` : ``
"Install miniconda if it hasn't been installed yet; _install_conda(true) installs Conda even if it has already been installed."
function _install_conda(env::Environment, force::Bool=false)
if force || !isfile(Conda.conda)
# This assumes that the conda executable will in some directory under
# CONDA_EXE_PREFIX.
# Ex: If CONDA_EXE="$HOME/miniforge3/bin/conda", then CONDA_EXE_PREFIX="$HOME/miniforge3"
CONDA_EXE_PREFIX = conda |> dirname |> dirname
@assert startswith(abspath(Conda.conda), abspath(PREFIX)) "CONDA_EXE, $(conda), does not exist within $PREFIX"
@info("Downloading miniconda installer ...")
if Sys.isunix()
installer = joinpath(CONDA_EXE_PREFIX, "installer.sh")
installer = joinpath(PREFIX, "installer.sh")
end
if Sys.iswindows()
installer = joinpath(CONDA_EXE_PREFIX, "installer.exe")
installer = joinpath(PREFIX, "installer.exe")
end
mkpath(CONDA_EXE_PREFIX)
mkpath(PREFIX)
Downloads.download(_installer_url(), installer)

@info("Installing miniconda ...")
if Sys.isunix()
chmod(installer, 33261) # 33261 corresponds to 755 mode of the 'chmod' program
run(`$installer -b -f -p $CONDA_EXE_PREFIX`)
run(`$installer -b -f -p $PREFIX`)
end
if Sys.iswindows()
run(Cmd(`$installer /S --no-shortcuts /NoRegistry=1 /AddToPath=0 /RegisterPython=0 /D=$PREFIX`, windows_verbatim=true))
Expand Down

0 comments on commit 8eb7c9a

Please sign in to comment.