File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 11import os
22import sys
3+ import jill .utils .version_utils
4+ import jill .install
35
46from time import time
57
68from . import CONFIG , __version__
7- from .jlcompat import JuliaCompat
9+ from .jlcompat import JuliaCompat , Version
810
911### META
1012
@@ -199,6 +201,33 @@ def required_julia():
199201 raise Exception ("'julia' compat entries have empty intersection:\n {}" .format ('\n ' .join (['- {!r} at {}' .format (v ,f ) for (f ,v ) in compats .items ()])))
200202 return compat
201203
204+ def best_julia_version ():
205+ """
206+ Selects the best Julia version available matching required_julia().
207+
208+ It's based on jill.utils.version_utils.latest_version() and jill.install.install_julia().
209+ """
210+ compat = required_julia ()
211+ system = jill .install .current_system ()
212+ arch = jill .install .current_architecture ()
213+ if system == 'linux' and jill .install .current_libc () == 'musl' :
214+ system = 'musl'
215+ releases = jill .utils .version_utils .read_releases ()
216+ releases = [r for r in releases if r [1 ]== system and r [2 ]== arch ]
217+ if compat is not None :
218+ _releases = releases
219+ releases = []
220+ for r in _releases :
221+ try :
222+ v = Version (r [0 ])
223+ if v in compat :
224+ releases .append (r )
225+ except :
226+ pass
227+ if not releases :
228+ raise Exception ('Did not find a version of Julia satisfying {!r}' .format (compat .jlstr ()))
229+ return max (releases , key = lambda x : jill .utils .version_utils .Version (x [0 ]))[0 ]
230+
202231def record_resolve (pkgs ):
203232 set_meta ("pydeps" , {
204233 "version" : __version__ ,
Original file line number Diff line number Diff line change 4242libpath = os .environ .get ('PYTHON_JULIACALL_LIB' )
4343if libpath is None :
4444 # Find the Julia executable...
45+ # TODO: Check the Julia executable is compatible with jlcompat
46+ # - If Julia is not found, install a compatible one.
47+ # - If Julia is found in the default prefix and not compatible, reinstall.
48+ # - If Julia is found elsewhere, emit a warning?
49+ jlcompat = deps .required_julia ()
4550 # ... in a specified location
4651 exepath = os .environ .get ('PYTHON_JULIACALL_EXE' )
4752 # ... in the default prefix
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ def __and__(self, other):
4646 return JuliaCompat (parts )
4747 def __repr__ (self ):
4848 return 'JuliaCompat({!r})' .format (self .parts )
49+ def __contains__ (self , v ):
50+ return any (v in p for p in self .parts )
4951
5052class Version :
5153 def __init__ (self , src ):
You can’t perform that action at this time.
0 commit comments