Skip to content

Commit fc6ea2d

Browse files
committed
Fetch available Julia versions from versions.json
1 parent b6e451d commit fc6ea2d

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

repo2docker/buildpacks/julia/julia_project.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Generates a Dockerfile based on an input matrix for Julia"""
2+
import functools
23
import os
4+
import requests
35
import toml
46
from ..python import PythonBuildPack
5-
from .semver import find_semver_match
7+
from .semver import find_semver_match, semver
68

79

810
class JuliaProjectTomlBuildPack(PythonBuildPack):
@@ -13,32 +15,24 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
1315
# ALL EXISTING JULIA VERSIONS
1416
# Note that these must remain ordered, in order for the find_semver_match()
1517
# function to behave correctly.
16-
all_julias = [
17-
"0.7.0",
18-
"1.0.0",
19-
"1.0.1",
20-
"1.0.2",
21-
"1.0.3",
22-
"1.0.4",
23-
"1.0.5",
24-
"1.1.0",
25-
"1.1.1",
26-
"1.2.0",
27-
"1.3.0",
28-
"1.3.1",
29-
"1.4.0",
30-
"1.4.1",
31-
"1.4.2",
32-
"1.5.0",
33-
"1.5.1",
34-
"1.5.2",
35-
"1.5.3",
36-
]
18+
@property
19+
@functools.lru_cache(maxsize=1)
20+
def all_julias(self):
21+
json = requests.get(
22+
"https://julialang-s3.julialang.org/bin/versions.json"
23+
).json()
24+
vers = [semver.VersionInfo.parse(v) for v in json.keys()]
25+
# filter out pre-release versions not supported by find_semver_match()
26+
filtered_vers = [v for v in vers if v.prerelease is None]
27+
# properly sort list of VersionInfo
28+
sorted_vers = sorted(
29+
filtered_vers, key=functools.cmp_to_key(semver.VersionInfo.compare)
30+
)
31+
# return list of semver string
32+
return [str(v) for v in sorted_vers]
3733

3834
@property
3935
def julia_version(self):
40-
default_julia_version = self.all_julias[-1]
41-
4236
if os.path.exists(self.binder_path("JuliaProject.toml")):
4337
project_toml = toml.load(self.binder_path("JuliaProject.toml"))
4438
else:
@@ -54,6 +48,7 @@ def julia_version(self):
5448
if _julia_version is not None:
5549
return _julia_version
5650

51+
default_julia_version = self.all_julias[-1]
5752
return default_julia_version
5853

5954
def get_build_env(self):

repo2docker/buildpacks/julia/semver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def match(self, v):
113113
while len(v) < 3:
114114
v = v + (0,)
115115
v_str = ".".join(map(str, v))
116-
return semver.match(v_str, self.constraint_str)
116+
v_ver = semver.VersionInfo.parse(v_str)
117+
return semver.VersionInfo.match(v_ver, self.constraint_str)
117118

118119
def __eq__(self, rhs):
119120
return self.constraint_str == rhs.constraint_str

0 commit comments

Comments
 (0)