Skip to content
Closed
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
8 changes: 4 additions & 4 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const programname = pysys(python, "executable")

# 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 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 All @@ -200,7 +200,7 @@ PYTHONHOME = if !haskey(ENV, "PYTHONHOME") || use_conda
exec_prefix = pysys(python, "exec_prefix")
is_windows() ? exec_prefix : pysys(python, "prefix") * ":" * exec_prefix
else
ENV["PYTHONHOME"]
get(ENV, "PYTHONHOME", nothing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at what Py_SetPythonHome does after we first got this going, maybe it would be easier to do get(ENV, "PYTHONHOME", "") and possibly not need the rest of the patch after this point. Dunno whether a user having the env var PYTHONHOME set to an empty string is sane and should be honored.

end

# cache the Python version as a Julia VersionNumber
Expand Down Expand Up @@ -238,8 +238,8 @@ writeifchanged("deps.jl", """
const pyprogramname = "$(escape_string(programname))"
const wpyprogramname = $(wstringconst(programname))
const pyversion_build = $(repr(pyversion))
const PYTHONHOME = "$(escape_string(PYTHONHOME))"
const wPYTHONHOME = $(wstringconst(PYTHONHOME))
const PYTHONHOME = $(PYTHONHOME == nothing ? nothing : "\"" * escape_string(PYTHONHOME) * "\"")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best way to do this

const wPYTHONHOME = $(PYTHONHOME == nothing ? nothing : wstringconst(PYTHONHOME))

"True if we are using the Python distribution in the Conda package."
const conda = $use_conda
Expand Down
2 changes: 1 addition & 1 deletion src/pyinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function __init__()
already_inited = 0 != ccall((@pysym :Py_IsInitialized), Cint, ())

if !already_inited
Py_SetPythonHome(libpy_handle, PYTHONHOME, wPYTHONHOME, pyversion)
PYTHONHOME != nothing && Py_SetPythonHome(libpy_handle, PYTHONHOME, wPYTHONHOME, pyversion)
if !isempty(pyprogramname)
if pyversion.major < 3
ccall((@pysym :Py_SetProgramName), Void, (Cstring,), pyprogramname)
Expand Down
2 changes: 1 addition & 1 deletion src/startup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if !symbols_present
# Only to be used at top-level - pointer will be invalid after reload
libpy_handle = Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
# need SetPythonHome to avoid warning, #299
Py_SetPythonHome(libpy_handle, PYTHONHOME, wPYTHONHOME, pyversion_build)
PYTHONHOME != nothing && Py_SetPythonHome(libpy_handle, PYTHONHOME, wPYTHONHOME, pyversion_build)
else
@static if is_windows()
pathbuf = Vector{UInt16}(1024)
Expand Down