Move path and env from traitlets to methods

pull/206/head
yuvipanda 2018-02-01 01:21:17 -08:00
rodzic dc653388f5
commit d3c6703e9e
4 zmienionych plików z 46 dodań i 42 usunięć

Wyświetl plik

@ -162,9 +162,8 @@ class BuildPack(LoggingConfigurable):
"npm", "npm",
} }
env = List( def get_env(self):
[], """
help="""
Ordered list of environment variables to be set for this image. Ordered list of environment variables to be set for this image.
Ordered so that environment variables can use other environment Ordered so that environment variables can use other environment
@ -173,17 +172,16 @@ class BuildPack(LoggingConfigurable):
Expects tuples, with the first item being the environment variable Expects tuples, with the first item being the environment variable
name and the second item being the value. name and the second item being the value.
""" """
) return []
path = List( def get_path(self):
[], """
help="""
Ordered list of file system paths to look for executables in. Ordered list of file system paths to look for executables in.
Just sets the PATH environment variable. Separated out since Just sets the PATH environment variable. Separated out since
it is very commonly set by various buildpacks. it is very commonly set by various buildpacks.
""" """
) return []
labels = Dict( labels = Dict(
{}, {},
@ -292,10 +290,9 @@ class BuildPack(LoggingConfigurable):
# FIXME: Temporary hack so we can refactor this piece by piece instead of all at once! # FIXME: Temporary hack so we can refactor this piece by piece instead of all at once!
result.get_packages = lambda: self.get_packages().union(other.get_packages()) result.get_packages = lambda: self.get_packages().union(other.get_packages())
result.get_base_packages = lambda: self.get_base_packages().union(other.get_base_packages()) result.get_base_packages = lambda: self.get_base_packages().union(other.get_base_packages())
result.get_path = lambda: self.get_path() + other.get_path()
result.get_env = lambda: self.get_env() + other.get_env()
result.path = self.path + other.path
# FIXME: Deduplicate Env
result.env = self.env + other.env
result.build_scripts = self.build_scripts + other.build_scripts result.build_scripts = self.build_scripts + other.build_scripts
result.assemble_scripts = (self.assemble_scripts + result.assemble_scripts = (self.assemble_scripts +
other.assemble_scripts) other.assemble_scripts)
@ -351,8 +348,8 @@ class BuildPack(LoggingConfigurable):
return t.render( return t.render(
packages=sorted(self.get_packages()), packages=sorted(self.get_packages()),
path=self.path, path=self.get_path(),
env=self.env, env=self.get_env(),
labels=self.labels, labels=self.labels,
build_script_directives=build_script_directives, build_script_directives=build_script_directives,
assemble_script_directives=assemble_script_directives, assemble_script_directives=assemble_script_directives,

Wyświetl plik

@ -19,12 +19,14 @@ HERE = os.path.dirname(os.path.abspath(__file__))
class CondaBuildPack(BuildPack): class CondaBuildPack(BuildPack):
name = "conda" name = "conda"
version = "0.1" version = "0.1"
env = [ def get_env(self):
('CONDA_DIR', '${APP_BASE}/conda'), return [
('NB_PYTHON_PREFIX', '${CONDA_DIR}'), ('CONDA_DIR', '${APP_BASE}/conda'),
] ('NB_PYTHON_PREFIX', '${CONDA_DIR}'),
]
path = ['${CONDA_DIR}/bin'] def get_path(self):
return ['${CONDA_DIR}/bin']
build_scripts = [ build_scripts = [
( (

Wyświetl plik

@ -9,17 +9,18 @@ from .base import BuildPack
class JuliaBuildPack(BuildPack): class JuliaBuildPack(BuildPack):
name = "julia" name = "julia"
version = "0.1" version = "0.1"
env = [
('JULIA_PATH', '${APP_BASE}/julia'),
('JULIA_HOME', '${JULIA_PATH}/bin'),
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
('JULIA_VERSION', '0.6.0'),
('JUPYTER', '${NB_PYTHON_PREFIX}/bin/jupyter')
]
path = [ def get_env(self):
'${JULIA_PATH}/bin' return [
] ('JULIA_PATH', '${APP_BASE}/julia'),
('JULIA_HOME', '${JULIA_PATH}/bin'),
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
('JULIA_VERSION', '0.6.0'),
('JUPYTER', '${NB_PYTHON_PREFIX}/bin/jupyter')
]
def get_path(self):
return ['${JULIA_PATH}/bin']
build_scripts = [ build_scripts = [
( (

Wyświetl plik

@ -17,15 +17,17 @@ class PythonBuildPack(BuildPack):
'python3-dev', 'python3-dev',
} }
env = [ def get_env(self):
("VENV_PATH", "${APP_BASE}/venv"), return [
# Prefix to use for installing kernels and finding jupyter binary ("VENV_PATH", "${APP_BASE}/venv"),
("NB_PYTHON_PREFIX", "${VENV_PATH}"), # Prefix to use for installing kernels and finding jupyter binary
] ("NB_PYTHON_PREFIX", "${VENV_PATH}"),
]
path = [ def get_path(self):
"${VENV_PATH}/bin" return [
] "${VENV_PATH}/bin"
]
build_script_files = { build_script_files = {
@ -100,13 +102,15 @@ class Python2BuildPack(BuildPack):
'python/requirements2.frozen.txt': '/tmp/requirements2.frozen.txt', 'python/requirements2.frozen.txt': '/tmp/requirements2.frozen.txt',
} }
env = [ def get_env(self):
('VENV2_PATH', '${APP_BASE}/venv2') return [
] ('VENV2_PATH', '${APP_BASE}/venv2')
]
path = [ def get_path(self):
"${VENV2_PATH}/bin" return [
] "${VENV2_PATH}/bin"
]
build_scripts = [ build_scripts = [
( (