Skip to content

Commit

Permalink
store prefs in depot_path/prefs
Browse files Browse the repository at this point in the history
As a stopgap until we get proper package options (JuliaLang/Juleps#38), store PYTHON preference in depot_path/prefs/PyCall so that they aren't forgotten when PyCall is updated
  • Loading branch information
stevengj authored Oct 12, 2018
1 parent 0bdcc10 commit 225baaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@ function whichfirst(args...)
return ""
end

const prefsfile = VERSION < v"0.7" ? "PYTHON" : joinpath(first(DEPOT_PATH), "prefs", "PyCall")
mkpath(dirname(prefsfile))

try # make sure deps.jl file is removed on error
python = try
let py = get(ENV, "PYTHON", isfile("PYTHON") ? readchomp("PYTHON") :
let py = get(ENV, "PYTHON", isfile(prefsfile) ? readchomp(prefsfile) :
(Compat.Sys.isunix() && !Compat.Sys.isapple()) || Sys.ARCH (:i686, :x86_64) ?
whichfirst("python3", "python") : "Conda"),
vers = isempty(py) || py == "Conda" ? v"0.0" : vparse(pyconfigvar(py,"VERSION","0.0"))
Expand Down Expand Up @@ -190,7 +193,7 @@ try # make sure deps.jl file is removed on error

# Get PYTHONHOME, either from the environment or from Python
# itself (if it is not in the environment or if we are using Conda)
PYTHONHOME = if !haskey(ENV, "PYTHONHOME") || use_conda
PYTHONHOME = if !haskey(ENV, "HOME") || use_conda
# PYTHONHOME tells python where to look for both pure python
# and binary modules. When it is set, it replaces both
# `prefix` and `exec_prefix` and we thus need to set it to
Expand Down Expand Up @@ -227,7 +230,7 @@ try # make sure deps.jl file is removed on error
""")

# Make subsequent builds (e.g. Pkg.update) use the same Python by default:
writeifchanged("PYTHON", use_conda ? "Conda" : isfile(programname) ? programname : python)
writeifchanged(prefsfile, use_conda ? "Conda" : isfile(programname) ? programname : python)

#########################################################################

Expand Down

0 comments on commit 225baaa

Please sign in to comment.