Skip to content

Commit f3a4edf

Browse files
author
Christopher Doris
committed
stop using pathof
1 parent 176fcf3 commit f3a4edf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/PythonCall.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module PythonCall
22

33
const VERSION = v"0.6.1"
4+
const ROOT_DIR = dirname(@__DIR__)
45

56
using Base: @propagate_inbounds
67
using MacroTools, Dates, Tables, Markdown, Serialization, Requires, Pkg

src/juliacall.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ function init_juliacall()
1616
# otherwise, Python is being embedded into Julia by PythonCall, so should not exist
1717
error("'juliacall' module already exists")
1818
else
19+
# TODO: Is there a more robust way to import juliacall from a specific path?
1920
# prepend the directory containing juliacall to sys.path
20-
sys.path.insert(0, joinpath(dirname(dirname(pathof(PythonCall))), "python"))
21+
sys.path.insert(0, joinpath(ROOT_DIR, "python"))
2122
# prevent juliacall from initialising itself
2223
os.environ["PYTHON_JULIACALL_NOINIT"] = "yes"
2324
# import juliacall
2425
pycopy!(jl, pyimport("juliacall"))
2526
# check the version
27+
@assert realpath(pystr_asstring(jl.__path__[0])) == realpath(joinpath(ROOT_DIR, "python", "juliacall"))
2628
@assert pystr_asstring(jl.__version__) == string(VERSION)
2729
@assert pybool_asbool(jl.CONFIG["noinit"])
2830
end

0 commit comments

Comments
 (0)