Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
runtime = os.getenv("PYJULIA_TEST_RUNTIME", "julia")
env_var = subprocess.check_output(
[runtime, "--startup-file=no", "-e", """
if VERSION < v"0.7-"
println("JULIA_PKGDIR")
print(ARGS[1])
else
paths = [ARGS[1], DEPOT_PATH[2:end]...]
println("JULIA_DEPOT_PATH")
print(join(paths, Sys.iswindows() ? ';' : ':'))
end
""", str(tmpdir)],
env=_enviorn,
universal_newlines=True)
name, val = env_var.split("\n", 1)
jlinfo = JuliaInfo.load(
runtime,
env=dict(_enviorn, **{name: val}))
check_core_juliainfo(jlinfo)
assert jlinfo.python is None
assert jlinfo.libpython_path is None
if VERSION < v"0.7-"
println("JULIA_PKGDIR")
print(ARGS[1])
else
paths = [ARGS[1], DEPOT_PATH[2:end]...]
println("JULIA_DEPOT_PATH")
print(join(paths, Sys.iswindows() ? ';' : ':'))
end
""", str(tmpdir)],
env=_enviorn,
universal_newlines=True)
name, val = env_var.split("\n", 1)
jlinfo = JuliaInfo.load(
runtime,
env=dict(_enviorn, **{name: val}))
check_core_juliainfo(jlinfo)
assert jlinfo.python is None
assert jlinfo.libpython_path is None
def runcode(python, code, check=False, **kwargs):
"""Run `code` in `python`."""
proc = run(
[python],
input=textwrap.dedent(code),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
env=dict(
_enviorn,
# Make PyJulia importable:
PYTHONPATH=os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "src"
),
),
**kwargs
)
print_completed_proc(proc)
if check:
assert proc.returncode == 0
return proc