kopia lustrzana https://github.com/jupyterhub/repo2docker
Fetch available Julia versions from versions.json
rodzic
b6e451dcda
commit
fc6ea2d53b
|
@ -1,8 +1,10 @@
|
||||||
"""Generates a Dockerfile based on an input matrix for Julia"""
|
"""Generates a Dockerfile based on an input matrix for Julia"""
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
import toml
|
import toml
|
||||||
from ..python import PythonBuildPack
|
from ..python import PythonBuildPack
|
||||||
from .semver import find_semver_match
|
from .semver import find_semver_match, semver
|
||||||
|
|
||||||
|
|
||||||
class JuliaProjectTomlBuildPack(PythonBuildPack):
|
class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
|
@ -13,32 +15,24 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
# ALL EXISTING JULIA VERSIONS
|
# ALL EXISTING JULIA VERSIONS
|
||||||
# Note that these must remain ordered, in order for the find_semver_match()
|
# Note that these must remain ordered, in order for the find_semver_match()
|
||||||
# function to behave correctly.
|
# function to behave correctly.
|
||||||
all_julias = [
|
@property
|
||||||
"0.7.0",
|
@functools.lru_cache(maxsize=1)
|
||||||
"1.0.0",
|
def all_julias(self):
|
||||||
"1.0.1",
|
json = requests.get(
|
||||||
"1.0.2",
|
"https://julialang-s3.julialang.org/bin/versions.json"
|
||||||
"1.0.3",
|
).json()
|
||||||
"1.0.4",
|
vers = [semver.VersionInfo.parse(v) for v in json.keys()]
|
||||||
"1.0.5",
|
# filter out pre-release versions not supported by find_semver_match()
|
||||||
"1.1.0",
|
filtered_vers = [v for v in vers if v.prerelease is None]
|
||||||
"1.1.1",
|
# properly sort list of VersionInfo
|
||||||
"1.2.0",
|
sorted_vers = sorted(
|
||||||
"1.3.0",
|
filtered_vers, key=functools.cmp_to_key(semver.VersionInfo.compare)
|
||||||
"1.3.1",
|
)
|
||||||
"1.4.0",
|
# return list of semver string
|
||||||
"1.4.1",
|
return [str(v) for v in sorted_vers]
|
||||||
"1.4.2",
|
|
||||||
"1.5.0",
|
|
||||||
"1.5.1",
|
|
||||||
"1.5.2",
|
|
||||||
"1.5.3",
|
|
||||||
]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def julia_version(self):
|
def julia_version(self):
|
||||||
default_julia_version = self.all_julias[-1]
|
|
||||||
|
|
||||||
if os.path.exists(self.binder_path("JuliaProject.toml")):
|
if os.path.exists(self.binder_path("JuliaProject.toml")):
|
||||||
project_toml = toml.load(self.binder_path("JuliaProject.toml"))
|
project_toml = toml.load(self.binder_path("JuliaProject.toml"))
|
||||||
else:
|
else:
|
||||||
|
@ -54,6 +48,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
if _julia_version is not None:
|
if _julia_version is not None:
|
||||||
return _julia_version
|
return _julia_version
|
||||||
|
|
||||||
|
default_julia_version = self.all_julias[-1]
|
||||||
return default_julia_version
|
return default_julia_version
|
||||||
|
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
|
|
|
@ -113,7 +113,8 @@ class SemverMatcher:
|
||||||
while len(v) < 3:
|
while len(v) < 3:
|
||||||
v = v + (0,)
|
v = v + (0,)
|
||||||
v_str = ".".join(map(str, v))
|
v_str = ".".join(map(str, v))
|
||||||
return semver.match(v_str, self.constraint_str)
|
v_ver = semver.VersionInfo.parse(v_str)
|
||||||
|
return semver.VersionInfo.match(v_ver, self.constraint_str)
|
||||||
|
|
||||||
def __eq__(self, rhs):
|
def __eq__(self, rhs):
|
||||||
return self.constraint_str == rhs.constraint_str
|
return self.constraint_str == rhs.constraint_str
|
||||||
|
|
Ładowanie…
Reference in New Issue