MilesCranmer commited on
Commit
7acebb6
1 Parent(s): 46f8a60

Standard names for JuliaCall env variables

Browse files
pysr/julia_import.py CHANGED
@@ -9,7 +9,7 @@ if "juliacall" in sys.modules:
9
  warnings.warn(
10
  "juliacall module already imported. "
11
  "Make sure that you have set the environment variable `PYTHON_JULIACALL_HANDLE_SIGNALS=yes` to avoid segfaults. "
12
- "Also note that PySR will not be able to configure `JULIA_NUM_THREADS` or `JULIA_OPTIMIZE` for you."
13
  )
14
  else:
15
  # Required to avoid segfaults (https://juliapy.github.io/PythonCall.jl/dev/faq/)
@@ -19,9 +19,9 @@ else:
19
  + "You will experience segfaults if running with multithreading."
20
  )
21
 
22
- if os.environ.get("JULIA_NUM_THREADS", "auto") != "auto":
23
  warnings.warn(
24
- "JULIA_NUM_THREADS environment variable is set to something other than 'auto', "
25
  "so PySR was not able to set it. You may wish to set it to `'auto'` for full use "
26
  "of your CPU."
27
  )
@@ -29,8 +29,8 @@ else:
29
  # TODO: Remove these when juliapkg lets you specify this
30
  for k, default in (
31
  ("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes"),
32
- ("JULIA_NUM_THREADS", "auto"),
33
- ("JULIA_OPTIMIZE", "3"),
34
  ):
35
  os.environ[k] = os.environ.get(k, default)
36
 
 
9
  warnings.warn(
10
  "juliacall module already imported. "
11
  "Make sure that you have set the environment variable `PYTHON_JULIACALL_HANDLE_SIGNALS=yes` to avoid segfaults. "
12
+ "Also note that PySR will not be able to configure `PYTHON_JULIACALL_THREADS` or `PYTHON_JULIACALL_OPTLEVEL` for you."
13
  )
14
  else:
15
  # Required to avoid segfaults (https://juliapy.github.io/PythonCall.jl/dev/faq/)
 
19
  + "You will experience segfaults if running with multithreading."
20
  )
21
 
22
+ if os.environ.get("PYTHON_JULIACALL_THREADS", "auto") != "auto":
23
  warnings.warn(
24
+ "PYTHON_JULIACALL_THREADS environment variable is set to something other than 'auto', "
25
  "so PySR was not able to set it. You may wish to set it to `'auto'` for full use "
26
  "of your CPU."
27
  )
 
29
  # TODO: Remove these when juliapkg lets you specify this
30
  for k, default in (
31
  ("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes"),
32
+ ("PYTHON_JULIACALL_THREADS", "auto"),
33
+ ("PYTHON_JULIACALL_OPTLEVEL", "3"),
34
  ):
35
  os.environ[k] = os.environ.get(k, default)
36
 
pysr/test/test_startup.py CHANGED
@@ -106,8 +106,8 @@ class TestStartup(unittest.TestCase):
106
  msg="PYTHON_JULIACALL_HANDLE_SIGNALS environment variable is set",
107
  ),
108
  dict(
109
- code='import os; os.environ["JULIA_NUM_THREADS"] = "1"; import pysr',
110
- msg="JULIA_NUM_THREADS environment variable is set",
111
  ),
112
  dict(
113
  code="import juliacall; import pysr",
 
106
  msg="PYTHON_JULIACALL_HANDLE_SIGNALS environment variable is set",
107
  ),
108
  dict(
109
+ code='import os; os.environ["PYTHON_JULIACALL_THREADS"] = "1"; import pysr',
110
+ msg="PYTHON_JULIACALL_THREADS environment variable is set",
111
  ),
112
  dict(
113
  code="import juliacall; import pysr",