Spaces:
Running
Running
Automatically disable precompilation for static binaries
Browse files- pysr/julia_helpers.py +12 -3
pysr/julia_helpers.py
CHANGED
|
@@ -65,7 +65,7 @@ def _get_io_arg(quiet):
|
|
| 65 |
return io_arg
|
| 66 |
|
| 67 |
|
| 68 |
-
def install(julia_project=None, quiet=False, precompile=
|
| 69 |
"""
|
| 70 |
Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
| 71 |
|
|
@@ -82,9 +82,12 @@ def install(julia_project=None, quiet=False, precompile=True): # pragma: no cov
|
|
| 82 |
os.environ["JULIA_PKG_PRECOMPILE_AUTO"] = "0"
|
| 83 |
|
| 84 |
julia.install(quiet=quiet)
|
| 85 |
-
Main = init_julia(julia_project, quiet=quiet)
|
| 86 |
io_arg = _get_io_arg(quiet)
|
| 87 |
|
|
|
|
|
|
|
|
|
|
| 88 |
if not precompile:
|
| 89 |
Main.eval('ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0')
|
| 90 |
|
|
@@ -157,7 +160,7 @@ def _check_for_conflicting_libraries(): # pragma: no cover
|
|
| 157 |
)
|
| 158 |
|
| 159 |
|
| 160 |
-
def init_julia(julia_project=None, quiet=False, julia_kwargs=None):
|
| 161 |
"""Initialize julia binary, turning off compiled modules if needed."""
|
| 162 |
global julia_initialized
|
| 163 |
global julia_kwargs_at_initialization
|
|
@@ -195,6 +198,10 @@ def init_julia(julia_project=None, quiet=False, julia_kwargs=None):
|
|
| 195 |
julia_kwargs = {**julia_kwargs, "compiled_modules": False}
|
| 196 |
Julia(**julia_kwargs)
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
from julia import Main as _Main
|
| 199 |
|
| 200 |
Main = _Main
|
|
@@ -234,6 +241,8 @@ def init_julia(julia_project=None, quiet=False, julia_kwargs=None):
|
|
| 234 |
julia_kwargs_at_initialization = julia_kwargs
|
| 235 |
|
| 236 |
julia_initialized = True
|
|
|
|
|
|
|
| 237 |
return Main
|
| 238 |
|
| 239 |
|
|
|
|
| 65 |
return io_arg
|
| 66 |
|
| 67 |
|
| 68 |
+
def install(julia_project=None, quiet=False, precompile=None): # pragma: no cover
|
| 69 |
"""
|
| 70 |
Install PyCall.jl and all required dependencies for SymbolicRegression.jl.
|
| 71 |
|
|
|
|
| 82 |
os.environ["JULIA_PKG_PRECOMPILE_AUTO"] = "0"
|
| 83 |
|
| 84 |
julia.install(quiet=quiet)
|
| 85 |
+
Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True)
|
| 86 |
io_arg = _get_io_arg(quiet)
|
| 87 |
|
| 88 |
+
if precompile is None and not init_log["compiled_modules"]:
|
| 89 |
+
precompile = False
|
| 90 |
+
|
| 91 |
if not precompile:
|
| 92 |
Main.eval('ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0')
|
| 93 |
|
|
|
|
| 160 |
)
|
| 161 |
|
| 162 |
|
| 163 |
+
def init_julia(julia_project=None, quiet=False, julia_kwargs=None, return_aux=False):
|
| 164 |
"""Initialize julia binary, turning off compiled modules if needed."""
|
| 165 |
global julia_initialized
|
| 166 |
global julia_kwargs_at_initialization
|
|
|
|
| 198 |
julia_kwargs = {**julia_kwargs, "compiled_modules": False}
|
| 199 |
Julia(**julia_kwargs)
|
| 200 |
|
| 201 |
+
using_compiled_modules = (not "compiled_modules" in julia_kwargs) or julia_kwargs[
|
| 202 |
+
"compiled_modules"
|
| 203 |
+
]
|
| 204 |
+
|
| 205 |
from julia import Main as _Main
|
| 206 |
|
| 207 |
Main = _Main
|
|
|
|
| 241 |
julia_kwargs_at_initialization = julia_kwargs
|
| 242 |
|
| 243 |
julia_initialized = True
|
| 244 |
+
if return_aux:
|
| 245 |
+
return Main, {"compiled_modules": using_compiled_modules}
|
| 246 |
return Main
|
| 247 |
|
| 248 |
|