Skip to content

Commit 26b5482

Browse files
authored
skip importing CondaPkg if not needed (take 3) (#769)
* skip importing CondaPkg if not needed * remove dependence on Pkg * apply suggestion * remove unused arg --------- Co-authored-by: Christopher Rowley <github.com/cjdoris>
1 parent fcb5502 commit 26b5482

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
99
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1010
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1111
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
12-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1312
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1413
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1514
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
@@ -22,7 +21,6 @@ Dates = "1"
2221
Libdl = "1"
2322
MacroTools = "0.5"
2423
Markdown = "1"
25-
Pkg = "1"
2624
Preferences = "1"
2725
PyCall = "1"
2826
Serialization = "1"

pysrc/juliacall/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def int_option(name, *, accept_auto=False, **kw):
135135
raise ValueError(f'{s}: expecting an int'+(' or auto' if accept_auto else ""))
136136

137137
def args_from_config(config):
138-
argv = [config['exepath']]
138+
argv = [config['exepath'], '--project='+config['project']]
139139
for opt, val in config.items():
140140
if opt.startswith('opt_'):
141141
if val is None:
@@ -264,10 +264,8 @@ def jlstr(x):
264264
script = '''
265265
try
266266
Base.require(Main, :CompilerSupportLibraries_jll)
267-
import Pkg
268267
global __PythonCall_libptr = Ptr{{Cvoid}}(UInt({}))
269268
ENV["JULIA_PYTHONCALL_EXE"] = {}
270-
Pkg.activate({}, io=devnull)
271269
using PythonCall
272270
catch err
273271
print(stderr, "ERROR: ")
@@ -278,7 +276,6 @@ def jlstr(x):
278276
'''.format(
279277
hex(c.pythonapi._handle),
280278
jlstr(sys.executable or ''),
281-
jlstr(project),
282279
)
283280
res = jl_eval(script.encode('utf8'))
284281
if res is None:

src/C/C.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ using ..Utils
99

1010
using Base: @kwdef
1111
using UnsafePointers: UnsafePtr
12-
using CondaPkg: CondaPkg
13-
using Pkg: Pkg
1412
using Libdl:
1513
dlpath, dlopen, dlopen_e, dlclose, dlsym, dlsym_e, RTLD_LAZY, RTLD_DEEPBIND, RTLD_GLOBAL
14+
using Preferences: @load_preference
15+
16+
# do not load CondaPkg if the exe preference is set to something else
17+
if @load_preference("exe", "@CondaPkg") == "@CondaPkg"
18+
using CondaPkg: CondaPkg
19+
end
1620

1721
import ..PythonCall:
1822
python_executable_path, python_library_path, python_library_handle, python_version

src/JlWrap/JlWrap.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import ..PythonCall:
3030
PyObjectMatrix,
3131
PyObjectArray
3232

33-
using Pkg: Pkg
3433
using Base: @propagate_inbounds, allocatedinline
3534

3635
import ..Core: Py
@@ -70,7 +69,6 @@ function __init__()
7069
jl.Core = Base.Core
7170
jl.Base = Base
7271
jl.Main = Main
73-
jl.Pkg = Pkg
7472
jl.PythonCall = PythonCall
7573
end
7674

0 commit comments

Comments
 (0)