|
1 | | -"""Generates a Dockerfile based on an input matrix with REQUIRE for legacy Julia""" |
| 1 | +""" |
| 2 | +DEPRECATED - Dependencies of REQUIRE have been removed |
| 3 | +""" |
2 | 4 |
|
3 | 5 | import os |
4 | | -from functools import lru_cache |
5 | 6 |
|
6 | | -from ...semver import parse_version as V |
7 | 7 | from ..python import PythonBuildPack |
8 | 8 |
|
9 | 9 |
|
10 | 10 | class JuliaRequireBuildPack(PythonBuildPack): |
11 | 11 | """ |
12 | 12 | Julia build pack which uses conda and REQUIRE. |
13 | | - """ |
14 | | - |
15 | | - minor_julias = {"0.6": "0.6.4", "0.7": "0.7.0", "1.0": "1.0.4", "1.1": "1.1.1"} |
16 | | - major_julias = {"1": "1.1.1"} |
17 | | - |
18 | | - @property |
19 | | - def python_version(self): |
20 | | - # IJulia doesn't build on julia 0.6 |
21 | | - # due to old incompatibilities with Jupyter-core >= 4.5, |
22 | | - # so use the similarly-old Python 3.5 base environment |
23 | | - if V(self.julia_version) < V("0.7"): |
24 | | - return "3.5" |
25 | | - else: |
26 | | - return super().python_version |
27 | | - |
28 | | - @property |
29 | | - def julia_version(self): |
30 | | - require = self.binder_path("REQUIRE") |
31 | | - try: |
32 | | - with open(require) as f: |
33 | | - julia_version_line = ( |
34 | | - f.readline().strip() |
35 | | - ) # First line is optionally a julia version |
36 | | - except FileNotFoundError: |
37 | | - julia_version_line = "" |
38 | | - |
39 | | - if not julia_version_line.startswith("julia "): |
40 | | - # not a Julia version line. |
41 | | - # use the default Julia. |
42 | | - self._julia_version = self.minor_julias["0.6"] |
43 | | - return self._julia_version |
44 | | - |
45 | | - julia_version_info = julia_version_line.split(" ", 1)[1].split(".") |
46 | | - julia_version = "" |
47 | | - if len(julia_version_info) == 1: |
48 | | - julia_version = self.major_julias[julia_version_info[0]] |
49 | | - elif len(julia_version_info) == 2: |
50 | | - # get major.minor |
51 | | - julia_version = self.minor_julias[".".join(julia_version_info)] |
52 | | - else: |
53 | | - # use supplied julia version |
54 | | - julia_version = ".".join(julia_version_info) |
55 | | - self._julia_version = julia_version |
56 | | - return self._julia_version |
57 | | - |
58 | | - @lru_cache() |
59 | | - def get_build_env(self): |
60 | | - """Get additional environment settings for Julia and Jupyter |
61 | | -
|
62 | | - Returns: |
63 | | - an ordered list of environment setting tuples |
64 | 13 |
|
65 | | - The tuples contain a string of the environment variable name and |
66 | | - a string of the environment setting: |
67 | | - - `JULIA_PATH`: base path where all Julia Binaries and libraries |
68 | | - will be installed |
69 | | - - `JULIA_HOME`: path where all Julia Binaries will be installed |
70 | | - - `JULIA_PKGDIR`: path where all Julia libraries will be installed |
71 | | - - `JULIA_DEPOT_PATH`: path where Julia libraries are installed. |
72 | | - Similar to JULIA_PKGDIR, used in 1.x. |
73 | | - - `JULIA_VERSION`: default version of julia to be installed |
74 | | - - `JULIA_ARCH`: machine architecture used in Julia download URLs |
75 | | - - `JULIA_ARCH_SHORT`: machine architecture used in Julia download URLs |
76 | | - - `JUPYTER`: environment variable required by IJulia to point to |
77 | | - the `jupyter` executable |
78 | | -
|
79 | | - For example, a tuple may be `('JULIA_VERSION', '0.6.0')`. |
80 | | -
|
81 | | - """ |
82 | | - if self.platform == "linux/arm64": |
83 | | - julia_arch = julia_arch_short = "aarch64" |
84 | | - else: |
85 | | - julia_arch = "x86_64" |
86 | | - julia_arch_short = "x64" |
87 | | - |
88 | | - if V(self.julia_version) < V("0.7"): |
89 | | - # IJulia with Julia 0.6 isn't compatible with more recent jupyter-core |
90 | | - # point it to the one in the kernel env |
91 | | - # I _think_ this is only relevant during installation |
92 | | - jupyter = "${KERNEL_PYTHON_PREFIX}/bin/jupyter" |
93 | | - else: |
94 | | - jupyter = "${NB_PYTHON_PREFIX}/bin/jupyter" |
95 | | - return super().get_build_env() + [ |
96 | | - ("JULIA_PATH", "${APP_BASE}/julia"), |
97 | | - ("JULIA_HOME", "${JULIA_PATH}/bin"), # julia <= 0.6 |
98 | | - ("JULIA_BINDIR", "${JULIA_HOME}"), # julia >= 0.7 |
99 | | - ("JULIA_PKGDIR", "${JULIA_PATH}/pkg"), |
100 | | - ("JULIA_DEPOT_PATH", "${JULIA_PKGDIR}"), # julia >= 0.7 |
101 | | - ("JULIA_VERSION", self.julia_version), |
102 | | - ("JULIA_ARCH", julia_arch), |
103 | | - ("JULIA_ARCH_SHORT", julia_arch_short), |
104 | | - ("JUPYTER", jupyter), |
105 | | - ] |
106 | | - |
107 | | - @lru_cache() |
108 | | - def get_path(self): |
109 | | - """Adds path to Julia binaries to user's PATH. |
110 | | -
|
111 | | - Returns: |
112 | | - an ordered list of path strings. The path to the Julia |
113 | | - executable is added to the list. |
114 | | -
|
115 | | - """ |
116 | | - return super().get_path() + ["${JULIA_HOME}"] |
117 | | - |
118 | | - @lru_cache() |
119 | | - def get_build_scripts(self): |
120 | | - """ |
121 | | - Return series of build-steps common to "ALL" Julia repositories |
122 | | -
|
123 | | - All scripts found here should be independent of contents of a |
124 | | - particular repository. |
125 | | -
|
126 | | - This creates a directory with permissions for installing julia packages |
127 | | - (from get_assemble_scripts). |
128 | | -
|
129 | | - """ |
130 | | - return super().get_build_scripts() + [ |
131 | | - ( |
132 | | - "root", |
133 | | - r""" |
134 | | - mkdir -p ${JULIA_PATH} && \ |
135 | | - curl -sSL "https://julialang-s3.julialang.org/bin/linux/${JULIA_ARCH_SHORT}/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-${JULIA_ARCH}.tar.gz" | tar -xz -C ${JULIA_PATH} --strip-components 1 |
136 | | - """, |
137 | | - ), |
138 | | - ( |
139 | | - "root", |
140 | | - r""" |
141 | | - mkdir -p ${JULIA_PKGDIR} && \ |
142 | | - chown ${NB_USER}:${NB_USER} ${JULIA_PKGDIR} |
143 | | - """, |
144 | | - ), |
145 | | - ( |
146 | | - "${NB_USER}", |
147 | | - # HACK: Can't seem to tell IJulia to install in sys-prefix |
148 | | - # FIXME: Find way to get it to install under /srv and not $HOME? |
149 | | - r""" |
150 | | - julia -e 'if (VERSION > v"0.7-") using Pkg; else Pkg.init(); end; Pkg.add("IJulia"); using IJulia;' && \ |
151 | | - mv ${HOME}/.local/share/jupyter/kernels/julia-${JULIA_VERSION%[.-]*} ${NB_PYTHON_PREFIX}/share/jupyter/kernels/julia-${JULIA_VERSION%[.-]*} |
152 | | - """, |
153 | | - ), |
154 | | - ] |
155 | | - |
156 | | - @lru_cache() |
157 | | - def get_assemble_scripts(self): |
158 | | - """ |
159 | | - Return series of build-steps specific to "this" Julia repository |
160 | | -
|
161 | | - Precompile all Julia libraries found in the repository's REQUIRE |
162 | | - file. The parent, CondaBuildPack, will add the build steps for |
163 | | - any needed Python packages found in environment.yml. |
164 | | -
|
165 | | - """ |
166 | | - require = self.binder_path("REQUIRE") |
167 | | - return super().get_assemble_scripts() + [ |
168 | | - ( |
169 | | - "${NB_USER}", |
170 | | - # Install and pre-compile all libraries if they've opted into it. |
171 | | - # In v0.6, Pkg.resolve() installs all the packages, but in v0.7+, we |
172 | | - # have to manually Pkg.add() each of them (since the REQUIRES file |
173 | | - # format is deprecated). |
174 | | - # The precompliation is done via `using {libraryname}`. |
175 | | - r""" |
176 | | - julia /tmp/install-repo-dependencies.jl "%(require)s" |
177 | | - """ |
178 | | - % {"require": require}, |
179 | | - # TODO: For some reason, `rm`ing the file fails with permission denied. |
180 | | - # && rm /tmp/install-repo-dependencies.jl |
181 | | - ) |
182 | | - ] |
| 14 | + Now just an informative error message. |
| 15 | + """ |
183 | 16 |
|
184 | | - @lru_cache() |
185 | | - def get_build_script_files(self): |
186 | | - files = { |
187 | | - "julia/install-repo-dependencies.jl": "/tmp/install-repo-dependencies.jl" |
188 | | - } |
189 | | - files.update(super().get_build_script_files()) |
190 | | - return files |
| 17 | + def build(self, *args, **kwargs): |
| 18 | + raise ValueError( |
| 19 | + "Julia REQUIRE no longer supported due to removed infrastructure. Use Project.toml." |
| 20 | + ) |
191 | 21 |
|
192 | 22 | def detect(self): |
193 | 23 | """ |
194 | | - Check if current repo should be built with the Julia Legacy Build pack |
195 | | -
|
196 | | - super().detect() is not called in this function - it would return |
197 | | - false unless an `environment.yml` is present and we do not want to |
198 | | - require the presence of a `environment.yml` to use Julia. |
199 | | -
|
200 | | - Instead we just check if the path to `REQUIRE` exists and that there is |
201 | | - no julia 1.0 style environment |
| 24 | + Check if current repo exects tp be built with the Julia Legacy Build pack |
202 | 25 |
|
| 26 | + This no longer works, but try to raise an informative error. |
203 | 27 | """ |
204 | 28 | return os.path.exists(self.binder_path("REQUIRE")) and not ( |
205 | 29 | os.path.exists(self.binder_path("Project.toml")) |
|
0 commit comments