From ab0221e457928846b75774d5101ded0e317623ac Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Wed, 6 Mar 2019 10:35:16 -0800 Subject: [PATCH 1/4] Use JULIA_PROJECT env variable to activate julia env --- repo2docker/buildpacks/julia/julia_project.py | 8 +++++++- tests/julia/julia_version-1.0.2/verify | 3 --- tests/julia/julia_version-default/verify | 3 --- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/repo2docker/buildpacks/julia/julia_project.py b/repo2docker/buildpacks/julia/julia_project.py index e9bd4fb8..d1a136f6 100644 --- a/repo2docker/buildpacks/julia/julia_project.py +++ b/repo2docker/buildpacks/julia/julia_project.py @@ -66,6 +66,12 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): ('JUPYTER', '${NB_PYTHON_PREFIX}/bin/jupyter') ] + def get_env(self): + return super().get_env() + [ + ('JULIA_PROJECT', '${REPO_DIR}') + ] + + def get_path(self): """Adds path to Julia binaries to user's PATH. @@ -118,7 +124,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): ( "${NB_USER}", r""" - julia -e "using Pkg; Pkg.add(\"IJulia\"); using IJulia; installkernel(\"Julia\", \"--project=${REPO_DIR}\", env=Dict(\"JUPYTER_DATA_DIR\"=>\"${NB_PYTHON_PREFIX}/share/jupyter\"));" && \ + JULIA_PROJECT="" julia -e "using Pkg; Pkg.add(\"IJulia\"); using IJulia; installkernel(\"Julia\", env=Dict(\"JUPYTER_DATA_DIR\"=>\"${NB_PYTHON_PREFIX}/share/jupyter\"));" && \ julia --project=${REPO_DIR} -e 'using Pkg; Pkg.instantiate(); pkg"precompile"' """ ) diff --git a/tests/julia/julia_version-1.0.2/verify b/tests/julia/julia_version-1.0.2/verify index e9168361..51b19d9a 100755 --- a/tests/julia/julia_version-1.0.2/verify +++ b/tests/julia/julia_version-1.0.2/verify @@ -4,9 +4,6 @@ if VERSION != v"1.0.2" exit(1) end -using Pkg -pkg"activate ." - try # Test that the package was installed. using IteratorInterfaceExtensions diff --git a/tests/julia/julia_version-default/verify b/tests/julia/julia_version-default/verify index 3518e515..46040d14 100755 --- a/tests/julia/julia_version-default/verify +++ b/tests/julia/julia_version-default/verify @@ -4,9 +4,6 @@ if VERSION < v"1.1.0" exit(1) end -using Pkg -pkg"activate ." - try # Test that the package was installed. using IteratorInterfaceExtensions From d75333e00fddf87e6ff502247507a74823a7738d Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Wed, 6 Mar 2019 20:16:23 -0800 Subject: [PATCH 2/4] Don't set JULIA_BINDIR env variable --- repo2docker/buildpacks/julia/julia_project.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/repo2docker/buildpacks/julia/julia_project.py b/repo2docker/buildpacks/julia/julia_project.py index d1a136f6..54572f44 100644 --- a/repo2docker/buildpacks/julia/julia_project.py +++ b/repo2docker/buildpacks/julia/julia_project.py @@ -49,7 +49,6 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): a string of the environment setting: - `JULIA_PATH`: base path where all Julia Binaries and libraries will be installed - - `JULIA_BINDIR`: path where all Julia Binaries will be installed - `JULIA_DEPOT_PATH`: path where Julia libraries are installed. - `JULIA_VERSION`: default version of julia to be installed - `JUPYTER`: environment variable required by IJulia to point to @@ -60,7 +59,6 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): """ return super().get_build_env() + [ ('JULIA_PATH', '${APP_BASE}/julia'), - ('JULIA_BINDIR', '${JULIA_PATH}/bin'), ('JULIA_DEPOT_PATH', '${JULIA_PATH}/pkg'), ('JULIA_VERSION', self.julia_version), ('JUPYTER', '${NB_PYTHON_PREFIX}/bin/jupyter') @@ -80,7 +78,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): executable is added to the list. """ - return super().get_path() + ['${JULIA_BINDIR}'] + return super().get_path() + ['${JULIA_PATH}/bin'] def get_build_scripts(self): """ From 65d4e6c0347e0f622cb14099fd2e4fdb335dca25 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Thu, 21 Mar 2019 12:55:19 -0700 Subject: [PATCH 3/4] Update changelog --- docs/source/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 661a4795..59903ce2 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -11,6 +11,8 @@ New features ------------ - Support for julia `Project.toml`, `JuliaProject.toml` and `Manifest.toml` files in :pr:`595` by :user:`davidanthoff` +- Set JULIA_PROJECT globally, so that every julia instance starts with the + julia environment activated in :pr:`612` by :user:`davidanthoff`. API changes ----------- From 787afc43ea77d8529300f2c0cb72cf5a6a49c4d5 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Thu, 21 Mar 2019 12:55:34 -0700 Subject: [PATCH 4/4] Add some code documentation --- repo2docker/buildpacks/julia/julia_project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/repo2docker/buildpacks/julia/julia_project.py b/repo2docker/buildpacks/julia/julia_project.py index f95433ae..64c2c8cb 100644 --- a/repo2docker/buildpacks/julia/julia_project.py +++ b/repo2docker/buildpacks/julia/julia_project.py @@ -113,6 +113,10 @@ class JuliaProjectTomlBuildPack(PythonBuildPack): """ Return series of build-steps specific to "this" Julia repository + We make sure that the IJulia package gets installed into the default + environment, and not the project specific one, by running the + IJulia install command with JULIA_PROJECT="". + Instantiate and then precompile all packages in the repos julia environment.