diff --git a/repo2docker/buildpacks/base.py b/repo2docker/buildpacks/base.py index b45c6c77..757ec384 100644 --- a/repo2docker/buildpacks/base.py +++ b/repo2docker/buildpacks/base.py @@ -162,9 +162,8 @@ class BuildPack(LoggingConfigurable): "npm", } - env = List( - [], - help=""" + def get_env(self): + """ Ordered list of environment variables to be set for this image. 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 name and the second item being the value. """ - ) + return [] - path = List( - [], - help=""" + def get_path(self): + """ Ordered list of file system paths to look for executables in. Just sets the PATH environment variable. Separated out since it is very commonly set by various buildpacks. """ - ) + return [] 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! 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_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.assemble_scripts = (self.assemble_scripts + other.assemble_scripts) @@ -351,8 +348,8 @@ class BuildPack(LoggingConfigurable): return t.render( packages=sorted(self.get_packages()), - path=self.path, - env=self.env, + path=self.get_path(), + env=self.get_env(), labels=self.labels, build_script_directives=build_script_directives, assemble_script_directives=assemble_script_directives, diff --git a/repo2docker/buildpacks/conda/__init__.py b/repo2docker/buildpacks/conda/__init__.py index d9720b50..f592dc5b 100644 --- a/repo2docker/buildpacks/conda/__init__.py +++ b/repo2docker/buildpacks/conda/__init__.py @@ -19,12 +19,14 @@ HERE = os.path.dirname(os.path.abspath(__file__)) class CondaBuildPack(BuildPack): name = "conda" version = "0.1" - env = [ - ('CONDA_DIR', '${APP_BASE}/conda'), - ('NB_PYTHON_PREFIX', '${CONDA_DIR}'), - ] + def get_env(self): + return [ + ('CONDA_DIR', '${APP_BASE}/conda'), + ('NB_PYTHON_PREFIX', '${CONDA_DIR}'), + ] - path = ['${CONDA_DIR}/bin'] + def get_path(self): + return ['${CONDA_DIR}/bin'] build_scripts = [ ( diff --git a/repo2docker/buildpacks/julia.py b/repo2docker/buildpacks/julia.py index 515ea39f..7a0afa39 100644 --- a/repo2docker/buildpacks/julia.py +++ b/repo2docker/buildpacks/julia.py @@ -9,17 +9,18 @@ from .base import BuildPack class JuliaBuildPack(BuildPack): name = "julia" 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 = [ - '${JULIA_PATH}/bin' - ] + def get_env(self): + 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 = [ ( diff --git a/repo2docker/buildpacks/python/__init__.py b/repo2docker/buildpacks/python/__init__.py index 7f444e41..5073df1b 100644 --- a/repo2docker/buildpacks/python/__init__.py +++ b/repo2docker/buildpacks/python/__init__.py @@ -17,15 +17,17 @@ class PythonBuildPack(BuildPack): 'python3-dev', } - env = [ - ("VENV_PATH", "${APP_BASE}/venv"), - # Prefix to use for installing kernels and finding jupyter binary - ("NB_PYTHON_PREFIX", "${VENV_PATH}"), - ] + def get_env(self): + return [ + ("VENV_PATH", "${APP_BASE}/venv"), + # Prefix to use for installing kernels and finding jupyter binary + ("NB_PYTHON_PREFIX", "${VENV_PATH}"), + ] - path = [ - "${VENV_PATH}/bin" - ] + def get_path(self): + return [ + "${VENV_PATH}/bin" + ] build_script_files = { @@ -100,13 +102,15 @@ class Python2BuildPack(BuildPack): 'python/requirements2.frozen.txt': '/tmp/requirements2.frozen.txt', } - env = [ - ('VENV2_PATH', '${APP_BASE}/venv2') - ] + def get_env(self): + return [ + ('VENV2_PATH', '${APP_BASE}/venv2') + ] - path = [ - "${VENV2_PATH}/bin" - ] + def get_path(self): + return [ + "${VENV2_PATH}/bin" + ] build_scripts = [ (