Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+1] Split julia support into pre julia 1.0 and post julia 1.0 #595

Merged
merged 52 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
36ade74
Add support for julia Project.toml files
davidanthoff Feb 24, 2019
0b1e6e6
Fix calls to julia_env_exists
davidanthoff Feb 24, 2019
4cc66dd
Fix IJulia installation
davidanthoff Feb 24, 2019
7f88531
Properly configure Project.toml location for IJulia kernel
davidanthoff Feb 25, 2019
c9770ee
Split julia support into legacy and current
davidanthoff Feb 25, 2019
3e9f8ec
Rearrange inputs
davidanthoff Feb 25, 2019
a08520c
Fix IJulia installation
davidanthoff Feb 25, 2019
e95300f
Add comments to julia pack
davidanthoff Feb 25, 2019
671836e
Rename julia tests
davidanthoff Feb 25, 2019
90ada02
Make julia path handling a bit more robust
davidanthoff Feb 26, 2019
dc661f2
Test a bugfix
davidanthoff Feb 26, 2019
26eecc7
Start reading julia version from Project.toml
davidanthoff Feb 26, 2019
8b1ef5c
Merge branch 'reorg-julia' of https://github.com/davidanthoff/repo2do…
davidanthoff Feb 26, 2019
9c2b66d
Enable a julia test again
davidanthoff Feb 26, 2019
bc0229a
Restructure files for julia
davidanthoff Feb 26, 2019
47e09b2
Rename julia build packs
davidanthoff Feb 26, 2019
a83fe40
Fix import bug in julia part of code
davidanthoff Feb 26, 2019
77fd0db
Fix julia test
davidanthoff Feb 28, 2019
7d7f238
Fix julia test
davidanthoff Feb 28, 2019
8afbcb6
Fix julia test bug
davidanthoff Feb 28, 2019
f3d0bf4
Add semver detection logic
davidanthoff Feb 28, 2019
86a3f00
Add julia semver code
NHDaly Mar 2, 2019
d09634c
Fix julia test
davidanthoff Mar 2, 2019
3b3d2c8
Fix Python 3.4 compat in julia code
davidanthoff Mar 2, 2019
c892f3f
Handle JuliaProject.toml properly
davidanthoff Mar 2, 2019
1a6d844
Fix typo in julia code
davidanthoff Mar 2, 2019
2320f5c
Fix another python 3.4 issue in julia code
davidanthoff Mar 2, 2019
5790933
Update documentation with new julia support
davidanthoff Mar 3, 2019
73a1a6d
Update docs/source/faq.rst
betatim Mar 5, 2019
6689ee3
Update docs/source/faq.rst
betatim Mar 5, 2019
3ba4c57
Merge branch 'master' into reorg-julia
davidanthoff Mar 5, 2019
2f8d43d
Update changelog
davidanthoff Mar 5, 2019
07bd9be
Update docs/source/changelog.rst
betatim Mar 5, 2019
bbf174e
Update repo2docker/buildpacks/julia/julia_semver.py
betatim Mar 5, 2019
97c66e9
Fix julia detection code
davidanthoff Mar 5, 2019
02c531d
Update julia tests
davidanthoff Mar 5, 2019
92e4121
Set file execution bit on julia tests
davidanthoff Mar 5, 2019
9600d4b
Fix changelog formatting
davidanthoff Mar 5, 2019
2134ae2
Change type in julia code
davidanthoff Mar 5, 2019
4eb13d4
Update repo2docker/buildpacks/julia/julia_require.py
willingc Mar 5, 2019
1e531a9
Update repo2docker/buildpacks/julia/julia_require.py
willingc Mar 5, 2019
4a882f4
Update docs/source/config_files.rst
NHDaly Mar 6, 2019
f6074aa
Update docs/source/faq.rst
NHDaly Mar 6, 2019
02ec93f
Update repo2docker/buildpacks/julia/julia_project.py
NHDaly Mar 6, 2019
606bc4c
Update julia README files
davidanthoff Mar 6, 2019
20b085c
Fix typo in julia code
davidanthoff Mar 6, 2019
0bbfb7c
Use proper version specifier in julia Project.toml test
davidanthoff Mar 6, 2019
e845db3
Update julia documentation
davidanthoff Mar 6, 2019
915173c
Add line feed at end of file
davidanthoff Mar 6, 2019
1684e2f
Remove JULIA_HOME env var for julia 1.0+
davidanthoff Mar 6, 2019
c3d4996
Remove JULIA_PKGDIR from julia Project.toml code
davidanthoff Mar 6, 2019
f718f9c
Fix version typo
betatim Mar 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion repo2docker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from . import __version__
from .buildpacks import (
PythonBuildPack, DockerBuildPack, LegacyBinderDockerBuildPack,
CondaBuildPack, JuliaBuildPack, RBuildPack, NixBuildPack
CondaBuildPack, JuliaBuildPack, JuliaLegacyBuildPack, RBuildPack, NixBuildPack
)
from . import contentproviders
from .utils import ByteSpecification, chdir
Expand Down Expand Up @@ -86,6 +86,7 @@ def _default_log_level(self):
LegacyBinderDockerBuildPack,
DockerBuildPack,
JuliaBuildPack,
JuliaLegacyBuildPack,
NixBuildPack,
RBuildPack,
CondaBuildPack,
Expand Down
1 change: 1 addition & 0 deletions repo2docker/buildpacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .python import PythonBuildPack
from .conda import CondaBuildPack
from .julia import JuliaBuildPack
from .julialegacy import JuliaLegacyBuildPack
davidanthoff marked this conversation as resolved.
Show resolved Hide resolved
from .docker import DockerBuildPack
from .legacy import LegacyBinderDockerBuildPack
from .r import RBuildPack
Expand Down
131 changes: 131 additions & 0 deletions repo2docker/buildpacks/julia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
"""Generates a Dockerfile based on an input matrix for Julia"""
import os
import toml
from .python import PythonBuildPack


class JuliaBuildPack(PythonBuildPack):
"""
Julia build pack which uses conda.
"""

minor_julias = {
'1.0': '1.0.3',
'1.1': '1.1.0',
}
major_julias = {
'1': '1.1.0',
}

@property
def julia_version(self):
# TODO Read version out of the file
# TODO Handle JuliaProject.toml
project_toml = toml.load(self.binder_path('Project.toml'))
if 'compat' in project_toml:
if 'julia' in project_toml['compat']:
return project_toml['compat']['julia']
return self.major_julias['1']

def get_build_env(self):
"""Get additional environment settings for Julia and Jupyter

Returns:
an ordered list of environment setting tuples

The tuples contain a string of the environment variable name and
a string of the environment setting:
- `JULIA_PATH`: base path where all Julia Binaries and libraries
will be installed
- `JULIA_HOME`: path where all Julia Binaries will be installed
- `JULIA_PKGDIR`: path where all Julia libraries will be installed
- `JULIA_DEPOT_PATH`: path where Julia libraries are installed.
Similar to JULIA_PKGDIR, used in 1.0.
- `JULIA_VERSION`: default version of julia to be installed
- `JUPYTER`: environment variable required by IJulia to point to
the `jupyter` executable

For example, a tuple may be `('JULIA_VERSION', '0.6.0')`.

"""
return super().get_build_env() + [
('JULIA_PATH', '${APP_BASE}/julia'),
('JULIA_HOME', '${JULIA_PATH}/bin'), # julia <= 0.6
('JULIA_BINDIR', '${JULIA_HOME}'), # julia >= 0.7
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
('JULIA_DEPOT_PATH', '${JULIA_PKGDIR}'), # julia >= 0.7
('JULIA_VERSION', self.julia_version),
('JUPYTER', '${NB_PYTHON_PREFIX}/bin/jupyter')
]

def get_path(self):
"""Adds path to Julia binaries to user's PATH.

Returns:
an ordered list of path strings. The path to the Julia
executable is added to the list.

"""
return super().get_path() + ['${JULIA_HOME}']

def get_build_scripts(self):
"""
Return series of build-steps common to "ALL" Julia repositories

All scripts found here should be independent of contents of a
particular repository.

This creates a directory with permissions for installing julia packages
(from get_assemble_scripts).

"""
return super().get_build_scripts() + [
(
"root",
r"""
mkdir -p ${JULIA_PATH} && \
curl -sSL "https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | tar -xz -C ${JULIA_PATH} --strip-components 1
"""
),
(
"root",
r"""
mkdir -p ${JULIA_PKGDIR} && \
chown ${NB_USER}:${NB_USER} ${JULIA_PKGDIR}
"""
),
]

def get_assemble_scripts(self):
"""
Return series of build-steps specific to "this" Julia repository

Instantiate and then precompile all packages in the repos julia
environment.

The parent, CondaBuildPack, will add the build steps for
any needed Python packages found in environment.yml.
"""
return super().get_assemble_scripts() + [
(
"${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=${REPO_DIR} -e 'using Pkg; Pkg.instantiate(); pkg"precompile"'
"""
)
]

def detect(self):
"""
Check if current repo should be built with the Julia Build pack

super().detect() is not called in this function - it would return
false unless an `environment.yml` is present and we do not want to
require the presence of a `environment.yml` to use Julia.

Instead we just check if the path to `Project.toml` or
`JuliaProject.toml` exists.

"""
return os.path.exists(self.binder_path('Project.toml')) or os.path.exists(self.binder_path('JuliaProject.toml'))
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ..python import PythonBuildPack


class JuliaBuildPack(PythonBuildPack):
class JuliaLegacyBuildPack(PythonBuildPack):
"""
Julia build pack which uses conda.
"""
Expand Down Expand Up @@ -150,21 +150,21 @@ def get_assemble_scripts(self):

def get_build_script_files(self):
files = {
'julia/install-repo-dependencies.jl': '/tmp/install-repo-dependencies.jl',
'julialegacy/install-repo-dependencies.jl': '/tmp/install-repo-dependencies.jl',
}
files.update(super().get_build_script_files())
return files

def detect(self):
"""
Check if current repo should be built with the Julia Build pack
Check if current repo should be built with the Julia Legacy Build pack

super().detect() is not called in this function - it would return
false unless an `environment.yml` is present and we do not want to
require the presence of a `environment.yml` to use Julia.

Instead we just check if the path to `REQUIRE` exists
Instead we just check if the path to `REQUIRE` exists and that there is
no julia 1.0 style environment

"""
# TODO(nhdaly): Add support for Project.toml here as well.
return os.path.exists(self.binder_path('REQUIRE'))
return os.path.exists(self.binder_path('REQUIRE')) and not(os.path.exists(self.binder_path('Project.toml')) or os.path.exists(self.binder_path('JuliaProject.toml')))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'escapism',
'jinja2',
'ruamel.yaml>=0.15',
'toml',
],
python_requires='>=3.4',
author='Project Jupyter Contributors',
Expand Down
2 changes: 2 additions & 0 deletions tests/julia/julia_version-1.1/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
5 changes: 2 additions & 3 deletions tests/julia/julia_version-1.1/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Julia - REQUIRE: test version for julia v1.1
Julia - Project.toml: test version for julia v1.1
---------------

Starting with julia v0.7 and up, the package manager has changed, so this tests
that the julia version can be specified and packages installed correctly.
Test a Project.toml file for julia.
davidanthoff marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 9 additions & 9 deletions tests/julia/julia_version-1.1/verify
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env julia
# Verify the version:
if VERSION < v"1.1" || VERSION >= v"1.2"
if VERSION < v"1" || VERSION >= v"2"
exit(1)
end

try
# Test that the package was installed.
using Compat
# try
# # Test that the package was installed.
# using IteratorInterfaceExtensions

# Verify that the environment variables are set correctly for julia 1.0+
@assert "julia" ∈ readdir(Sys.BINDIR)
catch
exit(1)
end
# # Verify that the environment variables are set correctly for julia 1.0+
# @assert "julia" ∈ readdir(Sys.BINDIR)
# catch
# exit(1)
# end
davidanthoff marked this conversation as resolved.
Show resolved Hide resolved

exit(0)
5 changes: 5 additions & 0 deletions tests/julia/julialegacy_version-1.1/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Julia - REQUIRE: test version for julia v1.1
---------------

Starting with julia v0.7 and up, the package manager has changed, so this tests
that the julia version can be specified and packages installed correctly.
17 changes: 17 additions & 0 deletions tests/julia/julialegacy_version-1.1/verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env julia
# Verify the version:
if VERSION < v"1.1" || VERSION >= v"1.2"
exit(1)
end

try
# Test that the package was installed.
using Compat

# Verify that the environment variables are set correctly for julia 1.0+
@assert "julia" ∈ readdir(Sys.BINDIR)
catch
exit(1)
end

exit(0)