-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathapi.jl
62 lines (54 loc) · 1.43 KB
/
api.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Conda
function PyPreferences.status()
# TODO: compare with in-process values
code = """
$(load_pypreferences_code())
PyPreferences.Implementations.status_inprocess()
"""
cmd = include_stdin_cmd()
open(pipeline(cmd; stdout = stdout, stderr = stderr); write = true) do io
write(io, code)
end
return
end
function PyPreferences.use_system(python::AbstractString = "python3")
"""
Use python from a provided executable or path (defaults to `python3`).
"""
return Implementations.set(python = python)
end
function PyPreferences.use_conda()
"""
Use Python provided by Conda.jl
"""
Conda.add("numpy")
return Implementations.set(conda = true)
end
#=
function use_jll()
end
=#
function PyPreferences.use_inprocess()
return Implementations.set(inprocess = true)
end
function PyPreferences.instruction_message()
return """
PyPreferences.jl is not configured properly. Run:
using Pkg
Pkg.add("PyPreferences")
using PyPreferences
@doc PyPreferences
for usage.
"""
end
function PyPreferences.assert_configured()
if (
PyPreferences.python === nothing ||
PyPreferences.python_fullpath === nothing ||
PyPreferences.libpython === nothing ||
PyPreferences.python_version === nothing ||
PyPreferences.PYTHONHOME === nothing
)
error(PyPreferences.instruction_message())
end
end