MilesCranmer commited on
Commit
6e53f4b
1 Parent(s): 3e5d906

Fix version check

Browse files
Files changed (2) hide show
  1. pysr/julia_helpers.py +5 -6
  2. pysr/sr.py +1 -1
pysr/julia_helpers.py CHANGED
@@ -32,10 +32,8 @@ def load_juliainfo():
32
 
33
 
34
  def _set_julia_project_env(julia_project, is_shared):
35
- juliainfo = load_juliainfo()
36
-
37
  if is_shared:
38
- if is_julia_version_greater_eq(juliainfo, (1, 7, 0)):
39
  os.environ["JULIA_PROJECT"] = "@" + str(julia_project)
40
  else:
41
  os.environ["JULIA_PROJECT"] = str(julia_project)
@@ -65,8 +63,7 @@ def install(julia_project=None, quiet=False): # pragma: no cover
65
  Main.eval("using Pkg")
66
 
67
  io = "devnull" if quiet else "stderr"
68
- juliainfo = load_juliainfo()
69
- io_arg = f"io={io}" if is_julia_version_greater_eq(juliainfo, (1, 6, 0)) else ""
70
 
71
  # Can't pass IO to Julia call as it evaluates to PyObject, so just directly
72
  # use Main.eval:
@@ -111,8 +108,10 @@ def _get_julia_project(julia_project):
111
  return julia_project, is_shared
112
 
113
 
114
- def is_julia_version_greater_eq(juliainfo, version=(1, 6, 0)):
115
  """Check if Julia version is greater than specified version."""
 
 
116
  current_version = (
117
  juliainfo.version_major,
118
  juliainfo.version_minor,
 
32
 
33
 
34
  def _set_julia_project_env(julia_project, is_shared):
 
 
35
  if is_shared:
36
+ if is_julia_version_greater_eq(version=(1, 7, 0)):
37
  os.environ["JULIA_PROJECT"] = "@" + str(julia_project)
38
  else:
39
  os.environ["JULIA_PROJECT"] = str(julia_project)
 
63
  Main.eval("using Pkg")
64
 
65
  io = "devnull" if quiet else "stderr"
66
+ io_arg = f"io={io}" if is_julia_version_greater_eq(version=(1, 6, 0)) else ""
 
67
 
68
  # Can't pass IO to Julia call as it evaluates to PyObject, so just directly
69
  # use Main.eval:
 
108
  return julia_project, is_shared
109
 
110
 
111
+ def is_julia_version_greater_eq(juliainfo=None, version=(1, 6, 0)):
112
  """Check if Julia version is greater than specified version."""
113
+ if juliainfo is None:
114
+ juliainfo = load_juliainfo()
115
  current_version = (
116
  juliainfo.version_major,
117
  juliainfo.version_minor,
pysr/sr.py CHANGED
@@ -1440,7 +1440,7 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
1440
  julia_project, is_shared = _get_julia_project(self.julia_project)
1441
  Main.eval("using Pkg")
1442
  io = "devnull" if update_verbosity == 0 else "stderr"
1443
- io_arg = f"io={io}" if is_julia_version_greater_eq(Main, (1, 6, 0)) else ""
1444
 
1445
  Main.eval(
1446
  f'Pkg.activate("{_escape_filename(julia_project)}", shared = Bool({int(is_shared)}), {io_arg})'
 
1440
  julia_project, is_shared = _get_julia_project(self.julia_project)
1441
  Main.eval("using Pkg")
1442
  io = "devnull" if update_verbosity == 0 else "stderr"
1443
+ io_arg = f"io={io}" if is_julia_version_greater_eq(version=(1, 6, 0)) else ""
1444
 
1445
  Main.eval(
1446
  f'Pkg.activate("{_escape_filename(julia_project)}", shared = Bool({int(is_shared)}), {io_arg})'