kopia lustrzana https://github.com/jupyterhub/repo2docker
rodzic
52be2d3d64
commit
1e1d6ac20f
|
@ -231,19 +231,8 @@ class BuildPack:
|
||||||
"support is experimental in repo2docker."
|
"support is experimental in repo2docker."
|
||||||
)
|
)
|
||||||
self.platform = ""
|
self.platform = ""
|
||||||
self._memoize()
|
|
||||||
|
|
||||||
def _memoize(self):
|
|
||||||
"""Memoize `get_foo` methods with lru_cache()
|
|
||||||
|
|
||||||
Avoids duplicate log statements when calling what should be idempotent methods more than once
|
|
||||||
"""
|
|
||||||
for method_name in dir(self):
|
|
||||||
if method_name.startswith("get_"):
|
|
||||||
method = getattr(self, method_name)
|
|
||||||
if callable(method):
|
|
||||||
setattr(self, method_name, lru_cache()(method))
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_packages(self):
|
def get_packages(self):
|
||||||
"""
|
"""
|
||||||
List of packages that are installed in this BuildPack.
|
List of packages that are installed in this BuildPack.
|
||||||
|
@ -253,6 +242,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_base_packages(self):
|
def get_base_packages(self):
|
||||||
"""
|
"""
|
||||||
Base set of apt packages that are installed for all images.
|
Base set of apt packages that are installed for all images.
|
||||||
|
@ -269,6 +259,7 @@ class BuildPack:
|
||||||
"unzip",
|
"unzip",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of environment variables to be set for this image.
|
Ordered list of environment variables to be set for this image.
|
||||||
|
@ -284,6 +275,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of environment variables to be set for this image.
|
Ordered list of environment variables to be set for this image.
|
||||||
|
@ -298,6 +290,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of file system paths to look for executables in.
|
Ordered list of file system paths to look for executables in.
|
||||||
|
@ -307,12 +300,14 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_labels(self):
|
def get_labels(self):
|
||||||
"""
|
"""
|
||||||
Docker labels to set on the built image.
|
Docker labels to set on the built image.
|
||||||
"""
|
"""
|
||||||
return self.labels
|
return self.labels
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_script_files(self):
|
def get_build_script_files(self):
|
||||||
"""
|
"""
|
||||||
Dict of files to be copied to the container image for use in building.
|
Dict of files to be copied to the container image for use in building.
|
||||||
|
@ -337,6 +332,7 @@ class BuildPack:
|
||||||
f"Found a stencila manifest.xml at {root}. Stencila is no longer supported."
|
f"Found a stencila manifest.xml at {root}. Stencila is no longer supported."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of shell script snippets to build the base image.
|
Ordered list of shell script snippets to build the base image.
|
||||||
|
@ -358,6 +354,7 @@ class BuildPack:
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_script_files(self):
|
def get_preassemble_script_files(self):
|
||||||
"""
|
"""
|
||||||
Dict of files to be copied to the container image for use in preassembly.
|
Dict of files to be copied to the container image for use in preassembly.
|
||||||
|
@ -371,6 +368,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of shell snippets to build an image for this repository.
|
Ordered list of shell snippets to build an image for this repository.
|
||||||
|
@ -387,6 +385,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of shell script snippets to build the repo into the image.
|
Ordered list of shell script snippets to build the repo into the image.
|
||||||
|
@ -413,6 +412,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_post_build_scripts(self):
|
def get_post_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
An ordered list of executable scripts to execute after build.
|
An ordered list of executable scripts to execute after build.
|
||||||
|
@ -425,6 +425,7 @@ class BuildPack:
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_start_script(self):
|
def get_start_script(self):
|
||||||
"""
|
"""
|
||||||
The path to a script to be executed at container start up.
|
The path to a script to be executed at container start up.
|
||||||
|
@ -637,12 +638,14 @@ class BuildPack:
|
||||||
|
|
||||||
|
|
||||||
class BaseImage(BuildPack):
|
class BaseImage(BuildPack):
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""Return env directives required for build"""
|
"""Return env directives required for build"""
|
||||||
return [
|
return [
|
||||||
("APP_BASE", "/srv"),
|
("APP_BASE", "/srv"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""Return env directives to be set after build"""
|
"""Return env directives to be set after build"""
|
||||||
return []
|
return []
|
||||||
|
@ -650,6 +653,7 @@ class BaseImage(BuildPack):
|
||||||
def detect(self):
|
def detect(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
scripts = []
|
scripts = []
|
||||||
try:
|
try:
|
||||||
|
@ -689,16 +693,19 @@ class BaseImage(BuildPack):
|
||||||
|
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""Return directives to run after the entire repository has been added to the image"""
|
"""Return directives to run after the entire repository has been added to the image"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_post_build_scripts(self):
|
def get_post_build_scripts(self):
|
||||||
post_build = self.binder_path("postBuild")
|
post_build = self.binder_path("postBuild")
|
||||||
if os.path.exists(post_build):
|
if os.path.exists(post_build):
|
||||||
return [post_build]
|
return [post_build]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_start_script(self):
|
def get_start_script(self):
|
||||||
start = self.binder_path("start")
|
start = self.binder_path("start")
|
||||||
if os.path.exists(start):
|
if os.path.exists(start):
|
||||||
|
|
|
@ -3,6 +3,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import warnings
|
import warnings
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ class CondaBuildPack(BaseImage):
|
||||||
return "linux-aarch64"
|
return "linux-aarch64"
|
||||||
raise ValueError(f"Unknown platform {self.platform}")
|
raise ValueError(f"Unknown platform {self.platform}")
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""Return environment variables to be set.
|
"""Return environment variables to be set.
|
||||||
|
|
||||||
|
@ -88,11 +90,13 @@ class CondaBuildPack(BaseImage):
|
||||||
env.append(("KERNEL_PYTHON_PREFIX", "${NB_PYTHON_PREFIX}"))
|
env.append(("KERNEL_PYTHON_PREFIX", "${NB_PYTHON_PREFIX}"))
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""Make kernel env the default for `conda install`"""
|
"""Make kernel env the default for `conda install`"""
|
||||||
env = super().get_env() + [("CONDA_DEFAULT_ENV", "${KERNEL_PYTHON_PREFIX}")]
|
env = super().get_env() + [("CONDA_DEFAULT_ENV", "${KERNEL_PYTHON_PREFIX}")]
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""Return paths (including conda environment path) to be added to
|
"""Return paths (including conda environment path) to be added to
|
||||||
the PATH environment variable.
|
the PATH environment variable.
|
||||||
|
@ -107,6 +111,7 @@ class CondaBuildPack(BaseImage):
|
||||||
path.append("${NPM_DIR}/bin")
|
path.append("${NPM_DIR}/bin")
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps common to all Python 3 repositories.
|
Return series of build-steps common to all Python 3 repositories.
|
||||||
|
@ -145,6 +150,7 @@ class CondaBuildPack(BaseImage):
|
||||||
|
|
||||||
major_pythons = {"2": "2.7", "3": "3.7"}
|
major_pythons = {"2": "2.7", "3": "3.7"}
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_script_files(self):
|
def get_build_script_files(self):
|
||||||
"""
|
"""
|
||||||
Dict of files to be copied to the container image for use in building.
|
Dict of files to be copied to the container image for use in building.
|
||||||
|
@ -359,6 +365,7 @@ class CondaBuildPack(BaseImage):
|
||||||
self.kernel_env_cutoff_version
|
self.kernel_env_cutoff_version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_script_files(self):
|
def get_preassemble_script_files(self):
|
||||||
"""preassembly only requires environment.yml
|
"""preassembly only requires environment.yml
|
||||||
|
|
||||||
|
@ -372,6 +379,7 @@ class CondaBuildPack(BaseImage):
|
||||||
assemble_files[environment_yml] = environment_yml
|
assemble_files[environment_yml] = environment_yml
|
||||||
return assemble_files
|
return assemble_files
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env_scripts(self):
|
def get_env_scripts(self):
|
||||||
"""Return series of build-steps specific to this source repository."""
|
"""Return series of build-steps specific to this source repository."""
|
||||||
scripts = []
|
scripts = []
|
||||||
|
@ -438,12 +446,14 @@ class CondaBuildPack(BaseImage):
|
||||||
]
|
]
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
scripts = super().get_preassemble_scripts()
|
scripts = super().get_preassemble_scripts()
|
||||||
if self._should_preassemble_env:
|
if self._should_preassemble_env:
|
||||||
scripts.extend(self.get_env_scripts())
|
scripts.extend(self.get_env_scripts())
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
scripts = super().get_assemble_scripts()
|
scripts = super().get_assemble_scripts()
|
||||||
if not self._should_preassemble_env:
|
if not self._should_preassemble_env:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Generates a Dockerfile based on an input matrix for Julia"""
|
"""Generates a Dockerfile based on an input matrix for Julia"""
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import semver
|
import semver
|
||||||
|
@ -19,7 +20,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
# 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.
|
||||||
@property
|
@property
|
||||||
@functools.lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def all_julias(self):
|
def all_julias(self):
|
||||||
try:
|
try:
|
||||||
json = requests.get(
|
json = requests.get(
|
||||||
|
@ -67,6 +68,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
raise RuntimeError("Failed to find a matching Julia version: {compat}")
|
raise RuntimeError("Failed to find a matching Julia version: {compat}")
|
||||||
return match
|
return match
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""Get additional environment settings for Julia and Jupyter
|
"""Get additional environment settings for Julia and Jupyter
|
||||||
|
|
||||||
|
@ -109,9 +111,11 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
else:
|
else:
|
||||||
return "${REPO_DIR}"
|
return "${REPO_DIR}"
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
return super().get_env() + [("JULIA_PROJECT", self.project_dir)]
|
return super().get_env() + [("JULIA_PROJECT", self.project_dir)]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""Adds path to Julia binaries to user's PATH.
|
"""Adds path to Julia binaries to user's PATH.
|
||||||
|
|
||||||
|
@ -122,6 +126,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
"""
|
"""
|
||||||
return super().get_path() + ["${JULIA_PATH}/bin"]
|
return super().get_path() + ["${JULIA_PATH}/bin"]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps common to "ALL" Julia repositories
|
Return series of build-steps common to "ALL" Julia repositories
|
||||||
|
@ -150,6 +155,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps specific to "this" Julia repository
|
Return series of build-steps specific to "this" Julia repository
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Generates a Dockerfile based on an input matrix with REQUIRE for legacy Julia"""
|
"""Generates a Dockerfile based on an input matrix with REQUIRE for legacy Julia"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from ...semver import parse_version as V
|
from ...semver import parse_version as V
|
||||||
from ..python import PythonBuildPack
|
from ..python import PythonBuildPack
|
||||||
|
@ -54,6 +55,7 @@ class JuliaRequireBuildPack(PythonBuildPack):
|
||||||
self._julia_version = julia_version
|
self._julia_version = julia_version
|
||||||
return self._julia_version
|
return self._julia_version
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""Get additional environment settings for Julia and Jupyter
|
"""Get additional environment settings for Julia and Jupyter
|
||||||
|
|
||||||
|
@ -102,6 +104,7 @@ class JuliaRequireBuildPack(PythonBuildPack):
|
||||||
("JUPYTER", jupyter),
|
("JUPYTER", jupyter),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""Adds path to Julia binaries to user's PATH.
|
"""Adds path to Julia binaries to user's PATH.
|
||||||
|
|
||||||
|
@ -112,6 +115,7 @@ class JuliaRequireBuildPack(PythonBuildPack):
|
||||||
"""
|
"""
|
||||||
return super().get_path() + ["${JULIA_HOME}"]
|
return super().get_path() + ["${JULIA_HOME}"]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps common to "ALL" Julia repositories
|
Return series of build-steps common to "ALL" Julia repositories
|
||||||
|
@ -149,6 +153,7 @@ class JuliaRequireBuildPack(PythonBuildPack):
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps specific to "this" Julia repository
|
Return series of build-steps specific to "this" Julia repository
|
||||||
|
@ -176,6 +181,7 @@ class JuliaRequireBuildPack(PythonBuildPack):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_script_files(self):
|
def get_build_script_files(self):
|
||||||
files = {
|
files = {
|
||||||
"julia/install-repo-dependencies.jl": "/tmp/install-repo-dependencies.jl"
|
"julia/install-repo-dependencies.jl": "/tmp/install-repo-dependencies.jl"
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
"""BuildPack for nixpkgs environments"""
|
"""BuildPack for nixpkgs environments"""
|
||||||
import os
|
import os
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from ..base import BaseImage, BuildPack
|
from ..base import BaseImage
|
||||||
|
|
||||||
|
|
||||||
class NixBuildPack(BaseImage):
|
class NixBuildPack(BaseImage):
|
||||||
"""A nix Package Manager BuildPack"""
|
"""A nix Package Manager BuildPack"""
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""Return paths to be added to PATH environemnt variable"""
|
"""Return paths to be added to PATH environemnt variable"""
|
||||||
return super().get_path() + ["/home/${NB_USER}/.nix-profile/bin"]
|
return super().get_path() + ["/home/${NB_USER}/.nix-profile/bin"]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""Ordered list of environment variables to be set for this image"""
|
"""Ordered list of environment variables to be set for this image"""
|
||||||
|
|
||||||
|
@ -20,6 +23,7 @@ class NixBuildPack(BaseImage):
|
||||||
("GIT_SSL_CAINFO", "/etc/ssl/certs/ca-certificates.crt"),
|
("GIT_SSL_CAINFO", "/etc/ssl/certs/ca-certificates.crt"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps common to all nix repositories.
|
Return series of build-steps common to all nix repositories.
|
||||||
|
@ -55,6 +59,7 @@ class NixBuildPack(BaseImage):
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_script_files(self):
|
def get_build_script_files(self):
|
||||||
"""Dict of files to be copied to the container image for use in building"""
|
"""Dict of files to be copied to the container image for use in building"""
|
||||||
return {
|
return {
|
||||||
|
@ -62,6 +67,7 @@ class NixBuildPack(BaseImage):
|
||||||
"nix/nix-shell-wrapper": "/usr/local/bin/nix-shell-wrapper",
|
"nix/nix-shell-wrapper": "/usr/local/bin/nix-shell-wrapper",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""Return series of build-steps specific to this source repository."""
|
"""Return series of build-steps specific to this source repository."""
|
||||||
return super().get_assemble_scripts() + [
|
return super().get_assemble_scripts() + [
|
||||||
|
@ -75,6 +81,7 @@ class NixBuildPack(BaseImage):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_start_script(self):
|
def get_start_script(self):
|
||||||
"""The path to a script to be executed as ENTRYPOINT"""
|
"""The path to a script to be executed as ENTRYPOINT"""
|
||||||
# the shell wrapper script duplicates the behaviour of other buildpacks
|
# the shell wrapper script duplicates the behaviour of other buildpacks
|
||||||
|
|
|
@ -8,6 +8,7 @@ same as the Python or Conda build packs.
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ class PipfileBuildPack(CondaBuildPack):
|
||||||
self._python_version = self.major_pythons["3"]
|
self._python_version = self.major_pythons["3"]
|
||||||
return self._python_version
|
return self._python_version
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_script_files(self):
|
def get_preassemble_script_files(self):
|
||||||
"""Return files needed for preassembly"""
|
"""Return files needed for preassembly"""
|
||||||
files = super().get_preassemble_script_files()
|
files = super().get_preassemble_script_files()
|
||||||
|
@ -84,6 +86,7 @@ class PipfileBuildPack(CondaBuildPack):
|
||||||
files[path] = path
|
files[path] = path
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
"""scripts to run prior to staging the repo contents"""
|
"""scripts to run prior to staging the repo contents"""
|
||||||
scripts = super().get_preassemble_scripts()
|
scripts = super().get_preassemble_scripts()
|
||||||
|
@ -101,6 +104,7 @@ class PipfileBuildPack(CondaBuildPack):
|
||||||
)
|
)
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""Return series of build-steps specific to this repository."""
|
"""Return series of build-steps specific to this repository."""
|
||||||
# If we have either Pipfile.lock, Pipfile, or runtime.txt declare the
|
# If we have either Pipfile.lock, Pipfile, or runtime.txt declare the
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Generates Dockerfiles based on an input matrix based on Python."""
|
"""Generates Dockerfiles based on an input matrix based on Python."""
|
||||||
import os
|
import os
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from ...utils import is_local_pip_requirement, open_guess_encoding
|
from ...utils import is_local_pip_requirement, open_guess_encoding
|
||||||
from ..conda import CondaBuildPack
|
from ..conda import CondaBuildPack
|
||||||
|
@ -93,6 +94,7 @@ class PythonBuildPack(CondaBuildPack):
|
||||||
# allow assembly from subset
|
# allow assembly from subset
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_script_files(self):
|
def get_preassemble_script_files(self):
|
||||||
assemble_files = super().get_preassemble_script_files()
|
assemble_files = super().get_preassemble_script_files()
|
||||||
for name in ("requirements.txt", "requirements3.txt"):
|
for name in ("requirements.txt", "requirements3.txt"):
|
||||||
|
@ -101,6 +103,7 @@ class PythonBuildPack(CondaBuildPack):
|
||||||
assemble_files[requirements_txt] = requirements_txt
|
assemble_files[requirements_txt] = requirements_txt
|
||||||
return assemble_files
|
return assemble_files
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
"""Return scripts to run before adding the full repository"""
|
"""Return scripts to run before adding the full repository"""
|
||||||
scripts = super().get_preassemble_scripts()
|
scripts = super().get_preassemble_scripts()
|
||||||
|
@ -108,6 +111,7 @@ class PythonBuildPack(CondaBuildPack):
|
||||||
scripts.extend(self._get_pip_scripts())
|
scripts.extend(self._get_pip_scripts())
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""Return series of build steps that require the full repository"""
|
"""Return series of build steps that require the full repository"""
|
||||||
# If we have a runtime.txt & that's set to python-2.7,
|
# If we have a runtime.txt & that's set to python-2.7,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -142,6 +143,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
self._runtime = f"r-{str(self._checkpoint_date)}"
|
self._runtime = f"r-{str(self._checkpoint_date)}"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""
|
"""
|
||||||
Set custom env vars needed for RStudio to load
|
Set custom env vars needed for RStudio to load
|
||||||
|
@ -156,6 +158,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
("LD_LIBRARY_PATH", "${R_HOME}/lib:${LD_LIBRARY_PATH}"),
|
("LD_LIBRARY_PATH", "${R_HOME}/lib:${LD_LIBRARY_PATH}"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_path(self):
|
def get_path(self):
|
||||||
"""
|
"""
|
||||||
Return paths to be added to the PATH environment variable.
|
Return paths to be added to the PATH environment variable.
|
||||||
|
@ -165,6 +168,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
"""
|
"""
|
||||||
return super().get_path() + ["/usr/lib/rstudio-server/bin/"]
|
return super().get_path() + ["/usr/lib/rstudio-server/bin/"]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_env(self):
|
def get_build_env(self):
|
||||||
"""
|
"""
|
||||||
Return environment variables to be set.
|
Return environment variables to be set.
|
||||||
|
@ -178,6 +182,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
("R_LIBS_USER", "${APP_BASE}/rlibs")
|
("R_LIBS_USER", "${APP_BASE}/rlibs")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_packages(self):
|
def get_packages(self):
|
||||||
"""
|
"""
|
||||||
Return list of packages to be installed.
|
Return list of packages to be installed.
|
||||||
|
@ -195,6 +200,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
|
|
||||||
return super().get_packages().union(packages)
|
return super().get_packages().union(packages)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
|
def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
|
||||||
for i in range(max_days_prior):
|
for i in range(max_days_prior):
|
||||||
snapshots = requests.post(
|
snapshots = requests.post(
|
||||||
|
@ -219,6 +225,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_mran_snapshot_url(self, snapshot_date, max_days_prior=7):
|
def get_mran_snapshot_url(self, snapshot_date, max_days_prior=7):
|
||||||
for i in range(max_days_prior):
|
for i in range(max_days_prior):
|
||||||
try_date = snapshot_date - datetime.timedelta(days=i)
|
try_date = snapshot_date - datetime.timedelta(days=i)
|
||||||
|
@ -233,6 +240,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_cran_mirror_url(self, snapshot_date):
|
def get_cran_mirror_url(self, snapshot_date):
|
||||||
# Date after which we will use rspm + binary packages instead of MRAN + source packages
|
# Date after which we will use rspm + binary packages instead of MRAN + source packages
|
||||||
rspm_cutoff_date = datetime.date(2022, 1, 1)
|
rspm_cutoff_date = datetime.date(2022, 1, 1)
|
||||||
|
@ -242,6 +250,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
else:
|
else:
|
||||||
return self.get_mran_snapshot_url(snapshot_date)
|
return self.get_mran_snapshot_url(snapshot_date)
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_devtools_snapshot_url(self):
|
def get_devtools_snapshot_url(self):
|
||||||
"""
|
"""
|
||||||
Return url of snapshot to use for getting devtools install
|
Return url of snapshot to use for getting devtools install
|
||||||
|
@ -255,6 +264,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
# necessary apt packages.
|
# necessary apt packages.
|
||||||
return "https://packagemanager.rstudio.com/all/__linux__/bionic/2022-01-04+Y3JhbiwyOjQ1MjYyMTU7NzlBRkJEMzg"
|
return "https://packagemanager.rstudio.com/all/__linux__/bionic/2022-01-04+Y3JhbiwyOjQ1MjYyMTU7NzlBRkJEMzg"
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_build_scripts(self):
|
def get_build_scripts(self):
|
||||||
"""
|
"""
|
||||||
Return series of build-steps common to all R repositories
|
Return series of build-steps common to all R repositories
|
||||||
|
@ -349,6 +359,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
|
|
||||||
return super().get_build_scripts() + scripts
|
return super().get_build_scripts() + scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_script_files(self):
|
def get_preassemble_script_files(self):
|
||||||
files = super().get_preassemble_script_files()
|
files = super().get_preassemble_script_files()
|
||||||
installR_path = self.binder_path("install.R")
|
installR_path = self.binder_path("install.R")
|
||||||
|
@ -357,6 +368,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_preassemble_scripts(self):
|
def get_preassemble_scripts(self):
|
||||||
"""Install contents of install.R
|
"""Install contents of install.R
|
||||||
|
|
||||||
|
@ -382,6 +394,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
|
|
||||||
return super().get_preassemble_scripts() + scripts
|
return super().get_preassemble_scripts() + scripts
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_assemble_scripts(self):
|
def get_assemble_scripts(self):
|
||||||
"""Install the dependencies of or the repository itself"""
|
"""Install the dependencies of or the repository itself"""
|
||||||
assemble_scripts = super().get_assemble_scripts()
|
assemble_scripts = super().get_assemble_scripts()
|
||||||
|
|
Ładowanie…
Reference in New Issue