Skip to content

Commit 9be3ac6

Browse files
authored
Merge pull request #1216 from frankier/julia-binder-dir-project-toml
Create Julia projects based on binder/Project.toml when found
2 parents 37ce79a + 430565f commit 9be3ac6

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

repo2docker/buildpacks/julia/julia_project.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,15 @@ def get_build_env(self):
9393
("JUPYTER_DATA_DIR", "${NB_PYTHON_PREFIX}/share/jupyter"),
9494
]
9595

96+
@property
97+
def project_dir(self):
98+
if self.binder_dir:
99+
return "${REPO_DIR}/" + self.binder_dir
100+
else:
101+
return "${REPO_DIR}"
102+
96103
def get_env(self):
97-
return super().get_env() + [("JULIA_PROJECT", "${REPO_DIR}")]
104+
return super().get_env() + [("JULIA_PROJECT", self.project_dir)]
98105

99106
def get_path(self):
100107
"""Adds path to Julia binaries to user's PATH.
@@ -148,15 +155,19 @@ def get_assemble_scripts(self):
148155
The parent, CondaBuildPack, will add the build steps for
149156
any needed Python packages found in environment.yml.
150157
"""
151-
return super().get_assemble_scripts() + [
158+
scripts = super().get_assemble_scripts()
159+
scripts.append(
152160
(
153161
"${NB_USER}",
154162
r"""
155-
JULIA_PROJECT="" julia -e "using Pkg; Pkg.add(\"IJulia\"); using IJulia; installkernel(\"Julia\", \"--project=${REPO_DIR}\");" && \
156-
julia --project=${REPO_DIR} -e 'using Pkg; Pkg.instantiate(); Pkg.resolve(); pkg"precompile"'
157-
""",
163+
JULIA_PROJECT="" julia -e "using Pkg; Pkg.add(\"IJulia\"); using IJulia; installkernel(\"Julia\", \"--project={project}\");" && \
164+
julia --project={project} -e 'using Pkg; Pkg.instantiate(); Pkg.resolve(); pkg"precompile"'
165+
""".format(
166+
project=self.project_dir
167+
),
158168
)
159-
]
169+
)
170+
return scripts
160171

161172
def detect(self):
162173
"""

tests/julia/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
- Tests use of a `Project.toml` file for Julia, using the repo2docker default
1414
version of Julia as specified in `julia_project.py`.
1515

16-
### project-1.0.2
16+
### project-1.0.2-binder-dir
1717

1818
- Tests use of a `Project.toml` file for Julia, using a version of Julia
1919
specified via `julia = "=1.0.2"` in `Project.toml`'s `[compat]` section.
2020

21+
- Test use of a `.binder` directory.
22+
2123
### require
2224

2325
- Tests use of a `REQUIRE` file for Julia, using the repo2docker default version
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# A broken Project.toml, but the idea is that the test should ignore this file
2+
# anyhow as there is a .binder folder.
3+
#
4+
[deps]
5+
IteratorInterfaceExtensions = "invalid"
6+
7+
[compat]
8+
julia = "=1.0.invalid"

0 commit comments

Comments
 (0)