jupyterhub / repo2docker

Turn repositories into Jupyter-enabled Docker images
https://repo2docker.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.63k stars 362 forks source link

Julia default version suggestions #1375

Open fonsp opened 1 month ago

fonsp commented 1 month ago

Hey all! Thanks for the amazing work on repo2docker!! I was looking through the code and I have a suggestion for using Julia's Manifest.toml, and I can answer some questions about the default Julia version.

New: Julia version in Manifest

Since Julia 1.7, Manifest.toml has a new format (the old one is still backwards compatible). One feature of this new format is that the Manifest.toml contains a top-level field julia_version with the exact Julia version number that was used to resolve the Manifest:

https://pkgdocs.julialang.org/v1/toml-files/#Manifest.toml-entries

I think this is a good fit for repo2docker, as it allows automatically reproducing the exact Julia version. My suggestion is to use this as follows:

This will not change anything for older repositories that use the old Manifest format, since the top-level julia_version is not defined.

Questions in comments about the current semver algorithm

This code:

https://github.com/jupyterhub/repo2docker/blob/239c4f57f5a40f7241bb4b4746019eb173475ed8/repo2docker/buildpacks/julia/julia_project.py#L49-L67

finds the latest Julia version that is semver-compatible with the compat entry for julia in Project.toml. This seems to be working according to Julia Pkg spec, and this means:

Compat entry "1.6" is the same as "^1.6" (caret is default), which means [1.6.0, 2.0.0), see https://pkgdocs.julialang.org/v1/compatibility/#Caret-specifiers

So right now, this means that the latest Julia version will be installed: 1.11.1.

This FIXME comment:

The commented test is indeed meant to fail: the latest Julia version is intentional (because the fallback compat version is "1.6" which will resolve to latest 1.x).

If you want to test that compat can be used to define something other than the latest version, you could add this to Project.toml:

[compat]
julia = "~1.7"

And check v"1.7.0" <= VERSION < v"1.8.0".

This FIXME comment

The observed behaviour in the comment seems correct, the comment can be removed.

The default compat entry

https://github.com/jupyterhub/repo2docker/blob/239c4f57f5a40f7241bb4b4746019eb173475ed8/repo2docker/buildpacks/julia/julia_project.py#L65

This does not seem fully intentional. I think two good options here are: