|
1 | 1 | import datetime |
2 | 2 | import os |
| 3 | +import re |
3 | 4 | import warnings |
4 | 5 | from functools import lru_cache |
5 | 6 |
|
@@ -77,17 +78,31 @@ def r_version(self): |
77 | 78 |
|
78 | 79 | if not hasattr(self, "_r_version"): |
79 | 80 | _, version, date = self.runtime |
80 | | - # If runtime.txt is not set, or if it isn't of the form r-<version>-<yyyy>-<mm>-<dd>, |
| 81 | + # If runtime.txt is not set, or if it isn't of the form r-<version>-*, |
81 | 82 | # we don't use any of it in determining r version and just use the default |
82 | | - if version and date: |
| 83 | + if version: |
83 | 84 | r_version = version |
84 | 85 | # For versions of form x.y, we want to explicitly provide x.y.z - latest patchlevel |
85 | 86 | # available. Users can however explicitly specify the full version to get something specific |
86 | 87 | if r_version in version_map: |
87 | 88 | r_version = version_map[r_version] |
88 | | - elif len(r_version.split(".")) == 2: |
89 | | - # must have x.y.z version, add .0 for unrecognized (future) R versions |
90 | | - r_version += ".0" |
| 89 | + else: |
| 90 | + r_version_parts = r_version.split(".") |
| 91 | + if len(r_version_parts) == 3: |
| 92 | + self.log.info( |
| 93 | + f"Using R full version, {r_version}, provided by user." |
| 94 | + ) |
| 95 | + else: |
| 96 | + # repo2docker fails earlier with a meaningful message to the user. |
| 97 | + # If repo2docker doesn't fail here, repo2docker might fail later |
| 98 | + # without a meaningful message to the user. |
| 99 | + raise RuntimeError( |
| 100 | + f"R version {r_version} is not supported. Please open an issue at https://github.com/jupyterhub/repo2docker/issues/new/choose.", |
| 101 | + ) |
| 102 | + else: |
| 103 | + self.log.warning( |
| 104 | + f"R version unspecified, using default R version {r_version}. You can specify the R version in runtime.txt." |
| 105 | + ) |
91 | 106 |
|
92 | 107 | # translate to the full version string |
93 | 108 | self._r_version = r_version |
|
0 commit comments