Skip to content

Commit ca062fc

Browse files
author
Christopher Doris
committed
remove jill dependency
1 parent 1e88005 commit ca062fc

File tree

6 files changed

+40
-94
lines changed

6 files changed

+40
-94
lines changed

docs/src/juliacall.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ What to read next:
5858

5959
## [Managing Julia dependencies](@id julia-deps)
6060

61-
JuliaCall manages its Julia dependencies using [Pkg](https://pkgdocs.julialang.org/v1) for
62-
packages and [jill](https://pypi.org/project/jill/) for Julia itself.
61+
JuliaCall manages its Julia dependencies using [Pkg](https://pkgdocs.julialang.org/v1).
6362
If a suitable version of Julia is not found on your system, it will automatically be
64-
downloaded and installed into `~/.julia/pythoncall`.
63+
downloaded and installed into `~/.julia/pythoncall/julia-VERSION`.
6564
A Julia environment is automatically created when JuliaCall is loaded, is activated, and is
6665
initialised with at least PythonCall. If you are using a virtual or conda environment then
6766
the Julia environment is created there, otherwise a global environment is created at

juliacall/deps.py

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import json
22
import os
33
import sys
4+
import subprocess
45

56
from time import time
67

78
from . import CONFIG, __version__
8-
from .semver import JuliaCompat, Version, julia_version_str
9+
from .semver import JuliaCompat
10+
11+
def julia_version_str(exe):
12+
"""
13+
If exe is a julia executable, return its version as a string. Otherwise return None.
14+
"""
15+
try:
16+
proc = subprocess.run([exe, "--version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
17+
except:
18+
return
19+
words = proc.stdout.decode('utf-8').split()
20+
if len(words) < 3 or words[0].lower() != 'julia' or words[1].lower() != 'version':
21+
return
22+
return words[2]
923

1024
### META
1125

@@ -192,36 +206,6 @@ def required_julia():
192206
raise Exception("'julia' compat entries have empty intersection:\n{}".format('\n'.join(['- {!r} at {}'.format(v,f) for (f,v) in compats.items()])))
193207
return compat
194208

195-
def best_julia_version(compat=None, upstream=None):
196-
"""
197-
Selects the best Julia version available matching required_julia().
198-
199-
It's based on jill.utils.version_utils.latest_version() and jill.install.install_julia().
200-
"""
201-
if compat is None:
202-
compat = required_julia()
203-
import jill.utils.version_utils
204-
import jill.install
205-
system = jill.install.current_system()
206-
arch = jill.install.current_architecture()
207-
if system == 'linux' and jill.install.current_libc() == 'musl':
208-
system = 'musl'
209-
releases = jill.utils.version_utils.read_releases(upstream=upstream)
210-
releases = [r for r in releases if r[1]==system and r[2]==arch]
211-
if compat is not None:
212-
_releases = releases
213-
releases = []
214-
for r in _releases:
215-
try:
216-
v = Version(r[0])
217-
if v in compat:
218-
releases.append(r)
219-
except:
220-
pass
221-
if not releases:
222-
raise Exception('Did not find a version of Julia satisfying {!r}'.format(compat.jlstr()))
223-
return max(releases, key=lambda x: jill.utils.version_utils.Version(x[0]))[0]
224-
225209
def record_resolve(pkgs):
226210
save_meta({
227211
"meta_version": META_VERSION,

juliacall/init.py

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import os, os.path, ctypes as c, shutil, subprocess, jill.install as jli
2-
from . import CONFIG, __version__, deps, semver
1+
import os, os.path, ctypes as c, shutil, subprocess
2+
from . import CONFIG, __version__, deps, semver, install
33

44
# Determine if this is a development version of juliacall
55
# i.e. it is installed from the github repo, which contains Project.toml
@@ -15,9 +15,6 @@
1515
# Determine where to look for julia
1616
jldepot = os.environ.get("JULIA_DEPOT_PATH", "").split(";" if os.name == "nt" else ":")[0] or os.path.join(os.path.expanduser("~"), ".julia")
1717
jlprefix = os.path.join(jldepot, "pythoncall")
18-
jlbin = os.path.join(jlprefix, "bin")
19-
jlinstall = os.path.join(jlprefix, "install")
20-
jldownload = os.path.join(jlprefix, "download")
2118

2219
# Determine where to put the julia environment
2320
# TODO: Can we more direcly figure out the environment from which python was called? Maybe find the first PATH entry containing python?
@@ -50,7 +47,7 @@
5047
# Find the Julia executable
5148
exepath = os.environ.get('PYTHON_JULIACALL_EXE')
5249
if exepath is not None:
53-
v = semver.julia_version_str(exepath)
50+
v = deps.julia_version_str(exepath)
5451
if v is None:
5552
raise ValueError("PYTHON_JULIACALL_EXE={!r} does not exist".format(exepath))
5653
else:
@@ -64,47 +61,29 @@
6461
else:
6562
# Find the best available version
6663
exepath = None
67-
jill_upstream = os.getenv("JILL_UPSTREAM") or "Official"
68-
exever = deps.best_julia_version(compat, upstream=jill_upstream)
69-
v = semver.julia_version_str("julia")
70-
if v is not None and v == exever:
71-
exepath = "julia"
72-
elif os.path.isdir(jlbin):
73-
for f in os.listdir(jlbin):
74-
if f.startswith("julia"):
75-
x = os.path.join(jlbin, f)
76-
v = semver.julia_version_str(x)
77-
if v is not None and v == exever:
78-
exepath = x
79-
break
64+
exever, exeverinfo = install.best_julia_version(compat)
65+
default_exeprefix = os.path.join(jlprefix, 'julia-'+exever)
66+
default_exepath = os.path.join(default_exeprefix, 'bin', 'julia.exe' if os.name=='nt' else 'julia')
67+
for x in [default_exepath, 'julia']:
68+
v = deps.julia_version_str(x)
69+
if v is not None and v == exever:
70+
print(f'Found Julia {v} at {x!r}')
71+
exepath = x
72+
break
73+
elif v is not None:
74+
print(f'Found Julia {v} at {x!r} (but looking for Julia {exever})')
8075
# If no such version, install it
8176
if exepath is None:
82-
print("Installing Julia version {} to {!r}".format(exever, jlbin))
83-
os.makedirs(jldownload, exist_ok=True)
84-
d = os.getcwd()
85-
p = os.environ.get("PATH")
86-
try:
87-
if p is None:
88-
os.environ["PATH"] = jlbin
89-
else:
90-
os.environ["PATH"] += os.pathsep + jlbin
91-
os.chdir(jldownload)
92-
jli.install_julia(version=exever, confirm=True, install_dir=jlinstall, symlink_dir=jlbin, upstream=jill_upstream)
93-
finally:
94-
if p is None:
95-
del os.environ["PATH"]
96-
else:
97-
os.environ["PATH"] = p
98-
os.chdir(d)
99-
exepath = os.path.join(jlbin, "julia.cmd" if os.name == "nt" else "julia")
77+
install.install_julia(exeverinfo, default_exeprefix)
78+
exepath = default_exepath
10079
if not os.path.isfile(exepath):
101-
raise Exception('Installed julia in {!r} but cannot find it'.format(jlbin))
80+
raise Exception(f'Installed Julia in {default_exeprefix!r} but cannot find it')
10281
# Check the version is compatible
103-
v = semver.julia_version_str(exepath)
82+
v = deps.julia_version_str(exepath)
10483
assert v is not None and (compat is None or semver.Version(v) in compat)
10584
CONFIG['exever'] = v
10685
CONFIG['exepath'] = exepath
107-
libpath = subprocess.run([exepath, '--startup-file=no', '-O0', '--compile=min', '-e', 'import Libdl; print(abspath(Libdl.dlpath("libjulia")))'], stdout=(subprocess.PIPE)).stdout.decode('utf8')
86+
libpath = subprocess.run([exepath, '--startup-file=no', '-O0', '--compile=min', '-e', 'import Libdl; print(abspath(Libdl.dlpath("libjulia")))'], check=True, stdout=subprocess.PIPE).stdout.decode('utf8')
10887

10988
# Initialize Julia, including installing required packages
11089
d = os.getcwd()

juliacall/install.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def install_julia(ver, prefix):
114114
# download julia
115115
buf = download_julia(f)
116116
# include the version in the prefix
117-
print(f'Installing Julia to {prefix}')
117+
v = f['version']
118+
print(f'Installing Julia {v} to {prefix}')
118119
if os.path.exists(prefix):
119120
shutil.rmtree(prefix)
120121
if os.path.dirname(prefix):
@@ -182,7 +183,7 @@ def install_julia_dmg(f, buf, prefix):
182183
f.write(buf.read())
183184
# mount it
184185
mount = os.path.join(tmpdir, 'mount')
185-
subprocess.run(['hdiutil', 'mount', '-mount', 'required', '-mountpoint', mount, dmg], check=True, capture_output=True)
186+
subprocess.run(['hdiutil', 'mount', '-mount', 'required', '-mountpoint', mount, dmg], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
186187
try:
187188
# copy stuff out
188189
appdirs = [d for d in os.listdir(mount) if d.startswith('Julia') and d.endswith('.app')]
@@ -192,7 +193,7 @@ def install_julia_dmg(f, buf, prefix):
192193
shutil.copytree(srcdir, prefix, symlinks=True)
193194
finally:
194195
# unmount
195-
subprocess.run(['umount', mount], check=True, capture_output=True)
196+
subprocess.run(['umount', mount], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
196197

197198
julia_installers = {
198199
'.tar.gz': install_julia_tar_gz,

juliacall/semver.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import subprocess
2-
31
class JuliaCompat:
42
def __init__(self, src):
53
if isinstance(src, str):
@@ -140,16 +138,3 @@ def __contains__(self, v):
140138
return self.v0 <= v and v < self.v1
141139
def __repr__(self):
142140
return 'Range({!r}, {!r})'.format(self.v0, self.v1)
143-
144-
def julia_version_str(exe):
145-
"""
146-
If exe is a julia executable, return its version as a string. Otherwise return None.
147-
"""
148-
try:
149-
proc = subprocess.Popen([exe, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
150-
proc.wait()
151-
words = proc.stdout.read().decode("utf-8").split()
152-
assert words[0] == "julia" and words[1] == "version"
153-
return words[2]
154-
except:
155-
pass

setup.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ classifiers =
1414
zip_safe = False
1515
packages = juliacall
1616
python_requires = >=3.3, <4
17-
install_requires =
18-
jill ==0.9.7
1917

2018
[options.package_data]
2119
juliacall = *.json

0 commit comments

Comments
 (0)