Skip to content

Commit

Permalink
Change how Julia executable is resolved
Browse files Browse the repository at this point in the history
resolve_julia_executable() has now been refactored into two functions:
resolve_default_julia_executable() returns the Julia executable from PATH
and resolve_julia_executable() returns returns the executable set in
application settings.

Re spine-tools/Spine-Toolbox#2446
  • Loading branch information
soininen committed Feb 19, 2024
1 parent 4343413 commit d7c9f2f
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions spine_engine/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class AppSettings:

def __init__(self, settings):
"""
Init.
Args:
settings (dict)
"""
Expand Down Expand Up @@ -141,19 +139,36 @@ def resolve_current_python_interpreter():
return EMBEDDED_PYTHON # Use embedded <app_install_dir>/Tools/python.exe


def resolve_julia_executable(julia_path):
"""if given julia_path is empty, tries to find the path to Julia
in user's PATH env variable. If Julia is not found in PATH,
returns an empty string.
def resolve_julia_executable(settings):
"""Returns path to Julia executable from settings, and, if not set, path to default Julia executable.
Args:
settings (AppSettings): application settings
Returns:
str: path to Julia executable
"""
path = settings.value("appSettings/juliaPath")
if path:
return path
return resolve_default_julia_executable()


def resolve_default_julia_executable():
"""Returns path to default Julia executable.
Tries to find the path to Julia in user's PATH env variable.
If Julia is not found in PATH, returns an empty string.
Note: In the long run, we should decide whether this is something we want to do
because adding julia-x.x./bin/ dir to the PATH is not recommended because this
also exposes some .dlls to other programs on user's (windows) system. I.e. it
may break other programs, and this is why the Julia installer does not
add (and does not even offer the chance to add) Julia to PATH.
Returns:
str: path to Julia executable
"""
if julia_path != "":
return julia_path
return resolve_executable_from_path(JULIA_EXECUTABLE)


Expand Down

0 comments on commit d7c9f2f

Please sign in to comment.