Spaces:
Sleeping
Sleeping
Commit
·
af2a12d
1
Parent(s):
8801268
Add back missing `DEPOT_PATH` setting within Julia
Browse files- test/test_env.py +9 -0
test/test_env.py
CHANGED
|
@@ -14,20 +14,29 @@ class TestJuliaProject(unittest.TestCase):
|
|
| 14 |
with TemporaryDirectory() as tmpdir:
|
| 15 |
# Create a temp depot to store julia packages (and our custom env)
|
| 16 |
Main = julia_helpers.init_julia()
|
|
|
|
|
|
|
| 17 |
if "JULIA_DEPOT_PATH" not in os.environ:
|
| 18 |
old_env = None
|
| 19 |
os.environ["JULIA_DEPOT_PATH"] = tmpdir
|
| 20 |
else:
|
| 21 |
old_env = os.environ["JULIA_DEPOT_PATH"]
|
| 22 |
os.environ["JULIA_DEPOT_PATH"] = f"{tmpdir}:{os.environ['JULIA_DEPOT_PATH']}"
|
|
|
|
| 23 |
test_env_name = "@pysr_test_env"
|
| 24 |
julia_helpers.install(julia_project=test_env_name)
|
| 25 |
Main = julia_helpers.init_julia(julia_project=test_env_name)
|
|
|
|
|
|
|
| 26 |
Main.eval("using SymbolicRegression")
|
| 27 |
Main.eval("using Pkg")
|
|
|
|
|
|
|
| 28 |
cur_project_dir = Main.eval("splitdir(dirname(Base.active_project()))[1]")
|
| 29 |
potential_shared_project_dirs = Main.eval("Pkg.envdir(DEPOT_PATH[1])")
|
| 30 |
self.assertEqual(cur_project_dir, potential_shared_project_dirs)
|
|
|
|
|
|
|
| 31 |
Main.eval("pop!(DEPOT_PATH)")
|
| 32 |
if old_env is None:
|
| 33 |
del os.environ["JULIA_DEPOT_PATH"]
|
|
|
|
| 14 |
with TemporaryDirectory() as tmpdir:
|
| 15 |
# Create a temp depot to store julia packages (and our custom env)
|
| 16 |
Main = julia_helpers.init_julia()
|
| 17 |
+
|
| 18 |
+
# Set up env:
|
| 19 |
if "JULIA_DEPOT_PATH" not in os.environ:
|
| 20 |
old_env = None
|
| 21 |
os.environ["JULIA_DEPOT_PATH"] = tmpdir
|
| 22 |
else:
|
| 23 |
old_env = os.environ["JULIA_DEPOT_PATH"]
|
| 24 |
os.environ["JULIA_DEPOT_PATH"] = f"{tmpdir}:{os.environ['JULIA_DEPOT_PATH']}"
|
| 25 |
+
Main.eval(f'pushfirst!(DEPOT_PATH, "{julia_helpers._escape_filename(tmpdir)}")')
|
| 26 |
test_env_name = "@pysr_test_env"
|
| 27 |
julia_helpers.install(julia_project=test_env_name)
|
| 28 |
Main = julia_helpers.init_julia(julia_project=test_env_name)
|
| 29 |
+
|
| 30 |
+
# Try to use env:
|
| 31 |
Main.eval("using SymbolicRegression")
|
| 32 |
Main.eval("using Pkg")
|
| 33 |
+
|
| 34 |
+
# Assert we actually loaded it:
|
| 35 |
cur_project_dir = Main.eval("splitdir(dirname(Base.active_project()))[1]")
|
| 36 |
potential_shared_project_dirs = Main.eval("Pkg.envdir(DEPOT_PATH[1])")
|
| 37 |
self.assertEqual(cur_project_dir, potential_shared_project_dirs)
|
| 38 |
+
|
| 39 |
+
# Clean up:
|
| 40 |
Main.eval("pop!(DEPOT_PATH)")
|
| 41 |
if old_env is None:
|
| 42 |
del os.environ["JULIA_DEPOT_PATH"]
|