|
| 1 | +const PYCALL_UUID = Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0") |
| 2 | +const PYCALL_PKGID = Base.PkgId(PYCALL_UUID, "PyCall") |
| 3 | + |
1 | 4 | check_libpath(PyCall) = begin
|
2 | 5 | if realpath(PyCall.libpython) == realpath(CONFIG.libpath)
|
3 | 6 | # @info "libpython path agrees between PythonCall and PyCall" PythonCall.CONFIG.libpath PyCall.libpython
|
|
16 | 19 | # Check Python is initialized
|
17 | 20 | C.Py_IsInitialized() == 0 && error("Python is not already initialized.")
|
18 | 21 | CONFIG.isinitialized = CONFIG.preinitialized = true
|
| 22 | + elseif get(ENV, "JULIA_PYTHONCALL_EXE", "") == "PYCALL" |
| 23 | + # Import PyCall and use its choices for libpython |
| 24 | + PyCall = get(Base.loaded_modules, PYCALL_PKGID, nothing) |
| 25 | + if PyCall === nothing |
| 26 | + PyCall = Base.require(PYCALL_PKGID) |
| 27 | + end |
| 28 | + CONFIG.exepath = PyCall.python |
| 29 | + CONFIG.libpath = PyCall.libpython |
| 30 | + CONFIG.libptr = dlopen_e(CONFIG.libpath, CONFIG.dlopenflags) |
| 31 | + if CONFIG.libptr == C_NULL |
| 32 | + error("Python library $(repr(CONFIG.libpath)) (from PyCall) could not be opened.") |
| 33 | + end |
| 34 | + CONFIG.pyprogname = PyCall.pyprogramname |
| 35 | + CONFIG.pyhome = PyCall.PYTHONHOME |
| 36 | + # Check Python is initialized |
| 37 | + C.Py_IsInitialized() == 0 && error("Python is not already initialized.") |
| 38 | + CONFIG.isinitialized = CONFIG.preinitialized = true |
19 | 39 | else
|
20 | 40 | # Find Python executable
|
21 | 41 | exepath = something(
|
|
52 | 72 |
|
53 | 73 | Ensure either:
|
54 | 74 | - python3 or python is in your PATH
|
55 |
| - - JULIA_PYTHONCALL_EXE is "CONDA" or "CONDA:<env>" |
| 75 | + - JULIA_PYTHONCALL_EXE is "CONDA", "CONDA:<env>" or "PYCALL" |
56 | 76 | - JULIA_PYTHONCALL_EXE is the path to the Python executable
|
57 | 77 | """)
|
58 | 78 | end
|
|
96 | 116 | end
|
97 | 117 |
|
98 | 118 | # Compare libpath with PyCall
|
99 |
| - PyCall = get(Base.loaded_modules, Base.PkgId(Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0"), "PyCall"), nothing) |
| 119 | + PyCall = get(Base.loaded_modules, PYCALL_PKGID, nothing) |
100 | 120 | if PyCall === nothing
|
101 | 121 | @require PyCall="438e738f-606a-5dbb-bf0a-cddfbfd45ab0" check_libpath(PyCall)
|
102 | 122 | else
|
|
0 commit comments