Skip to content

Commit 5894f63

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/new-base
2 parents f848c81 + 21fa80f commit 5894f63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1215
-635
lines changed

.codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage:
66
status:
77
project:
88
default:
9-
target: auto
9+
target: "0%"
1010
patch:
1111
default:
12-
target: 20%
12+
target: "0%"

.github/workflows/docker.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/docker.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/docker.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/release.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/release.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- "**.rst"
1212
- ".github/workflows/*"
1313
- "!.github/workflows/test.yml"
14+
- ".pre-commit-config.yaml"
1415
push:
1516
paths-ignore:
1617
- "docs/**"
1718
- "**.md"
1819
- "**.rst"
1920
- ".github/workflows/*"
2021
- "!.github/workflows/test.yml"
22+
- ".pre-commit-config.yaml"
2123
branches-ignore:
2224
- "dependabot/**"
2325
- "pre-commit-ci-update-config"

.gitpod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
tasks:
22
- init: |
33
pip3 install sphinx-autobuild
4+
pip3 install -r dev-requirements.txt
45
pip3 install -r docs/requirements.txt
56
pip3 install -e .
67
command: |
78
sphinx-autobuild docs/source/ docs/_build/html/
89
name: Sphinx preview
10+
911
ports:
1012
- port: 8000

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323

2424
# Autoformat: Python code
2525
- repo: https://github.com/psf/black
26-
rev: 22.12.0
26+
rev: 23.1.0
2727
hooks:
2828
- id: black
2929
args:
@@ -36,15 +36,15 @@ repos:
3636

3737
# Autoformat: Python code
3838
- repo: https://github.com/pycqa/isort
39-
rev: 5.11.4
39+
rev: 5.12.0
4040
hooks:
4141
- id: isort
4242
args:
4343
- --profile=black
4444

4545
# Autoformat: markdown
4646
- repo: https://github.com/pre-commit/mirrors-prettier
47-
rev: v3.0.0-alpha.4
47+
rev: v3.0.0-alpha.6
4848
hooks:
4949
- id: prettier
5050
files: ".md"

docs/source/config_files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ specified in your ``environment.yml``.
4343
You can also specify which Python version to install in your built environment
4444
with ``environment.yml``. By default, ``repo2docker`` installs
4545
|default_python| with your ``environment.yml`` unless you include the version of
46-
Python in this file. ``conda`` supports all versions of Python,
47-
though ``repo2docker`` support is best with Python 3.7, 3.6, 3.5 and 2.7.
46+
Python in this file. ``conda`` Should support all versions of Python,
47+
though ``repo2docker`` support is best with Python 3.7-3.11.
4848

4949
.. warning::
5050
If you include a Python version in a ``runtime.txt`` file in addition to your

docs/source/faq.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Repo2docker officially supports the following versions of Python
2222
(specified in your :ref:`environment.yml <environment.yml>` or
2323
:ref:`runtime.txt <runtime.txt>` file):
2424

25+
- 3.11 (added in 2023)
26+
- 3.10 (added in 2022, default in 2023)
27+
- 3.9 (added in 2021)
28+
- 3.8 (added in 0.11)
2529
- 3.7 (added in 0.7, default in 0.8)
2630
- 3.6 (default in 0.7 and earlier)
2731
- 3.5
@@ -35,9 +39,18 @@ in the base environment is not packaged for your Python,
3539
either because the version of the package is too new and your chosen Python is too old,
3640
or vice versa.
3741

38-
I Python 2.7 is specified, a separate environment for the kernel will be
39-
installed with Python 2. The notebook server will run in the default Python 3.7
40-
environment.
42+
If an old version of Python is specified (3.6 or earlier in 2023), a separate environment for the kernel will be installed with your requested Python version.
43+
The notebook server will run in the default |default_python| environment.
44+
That is, your _notebooks_ will run with Python 3.6, while your notebook _server_ will run with |default_python|.
45+
46+
These two environments can be distinguished with ``$NB_PYTHON_PREFIX/bin/python`` for the server and ``$KERNEL_PYTHON_PREFIX/bin/python`` for the kernel.
47+
Both of these environment variables area always defined, even when they are the same.
48+
49+
Starting in 2023, the default version of Python used when Python version is unspecified will be updated more often.
50+
Python itself releases a new version every year now, and repo2docker will follow, with the default Python version generally trailing the latest stable version of Python itself by 1-2 versions.
51+
52+
If you choose not to specify a Python version, your repository is _guaranteed_ to stop working, eventually.
53+
We **strongly** recommend specifying a Python version (in environment.yml, runtime.txt, Pipfile, etc.)
4154

4255
Julia
4356
~~~~~

repo2docker/buildpacks/conda/__init__.py

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""BuildPack for conda environments"""
22
import os
33
import re
4+
import warnings
45
from collections.abc import Mapping
56

67
from ruamel.yaml import YAML
78

9+
from ...semver import parse_version as V
810
from ...utils import is_local_pip_requirement
911
from .._r_base import rstudio_base_scripts
1012
from ..base import BaseImage
@@ -98,7 +100,7 @@ def get_path(self):
98100
"""
99101
path = super().get_path()
100102
path.insert(0, "${CONDA_DIR}/bin")
101-
if self.py2:
103+
if self.separate_kernel_env:
102104
path.insert(0, "${KERNEL_PYTHON_PREFIX}/bin")
103105
path.insert(0, "${NB_PYTHON_PREFIX}/bin")
104106
# This is at the end of $PATH, for backwards compat reasons
@@ -141,7 +143,7 @@ def get_build_scripts(self):
141143
),
142144
]
143145

144-
major_pythons = {"2": "2.7", "3": "3.7"}
146+
major_pythons = {"2": "2.7", "3": "3.10"}
145147

146148
def get_build_script_files(self):
147149
"""
@@ -172,20 +174,24 @@ def get_build_script_files(self):
172174
frozen_name = f"environment-{self._conda_platform()}.lock"
173175
pip_frozen_name = "requirements.txt"
174176
if py_version:
175-
if self.python_version == "2.7":
176-
if "linux-64" != self._conda_platform():
177+
conda_platform = self._conda_platform()
178+
if self.separate_kernel_env:
179+
self.log.warning(
180+
f"User-requested packages for legacy Python version {py_version} will be installed in a separate kernel environment.\n"
181+
)
182+
lockfile_name = f"environment.py-{py_version}-{conda_platform}.lock"
183+
if not os.path.exists(os.path.join(HERE, lockfile_name)):
177184
raise ValueError(
178-
f"Python version 2.7 {self._conda_platform()} is not supported!"
185+
f"Python version {py_version} on {conda_platform} is not supported!"
179186
)
180-
181-
# python 2 goes in a different env
182187
files[
183-
"conda/environment.py-2.7-linux-64.lock"
188+
f"conda/{lockfile_name}"
184189
] = self._kernel_environment_file = "/tmp/env/kernel-environment.lock"
185-
# additional pip requirements for kernel env
186-
if os.path.exists(os.path.join(HERE, "requirements.py-2.7.txt")):
190+
191+
requirements_file_name = f"requirements.py-{py_version}.pip"
192+
if os.path.exists(os.path.join(HERE, requirements_file_name)):
187193
files[
188-
"conda/requirements.py-2.7.txt"
194+
f"conda/{requirements_file_name}"
189195
] = (
190196
self._kernel_requirements_file
191197
) = "/tmp/env/kernel-requirements.txt"
@@ -333,8 +339,26 @@ def uses_r(self):
333339
@property
334340
def py2(self):
335341
"""Am I building a Python 2 kernel environment?"""
342+
warnings.warn(
343+
"CondaBuildPack.py2 is deprecated in 2023.2. Use CondaBuildPack.separate_kernel_env.",
344+
DeprecationWarning,
345+
stacklevel=2,
346+
)
336347
return self.python_version and self.python_version.split(".")[0] == "2"
337348

349+
# Python versions _older_ than this get a separate kernel env
350+
kernel_env_cutoff_version = "3.7"
351+
352+
@property
353+
def separate_kernel_env(self):
354+
"""Whether the kernel should be installed into a separate env from the server
355+
356+
Applies to older versions of Python that aren't kept up-to-date
357+
"""
358+
return self.python_version and V(self.python_version) < V(
359+
self.kernel_env_cutoff_version
360+
)
361+
338362
def get_preassemble_script_files(self):
339363
"""preassembly only requires environment.yml
340364
@@ -352,7 +376,11 @@ def get_env_scripts(self):
352376
"""Return series of build-steps specific to this source repository."""
353377
scripts = []
354378
environment_yml = self.binder_path("environment.yml")
355-
env_prefix = "${KERNEL_PYTHON_PREFIX}" if self.py2 else "${NB_PYTHON_PREFIX}"
379+
env_prefix = (
380+
"${KERNEL_PYTHON_PREFIX}"
381+
if self.separate_kernel_env
382+
else "${NB_PYTHON_PREFIX}"
383+
)
356384
if os.path.exists(environment_yml):
357385
# TODO: when using micromamba, we call $MAMBA_EXE install -p ...
358386
# whereas mamba/conda need `env update -p ...` when it's an env.yaml file
@@ -396,6 +424,7 @@ def get_env_scripts(self):
396424
echo auth-none=1 >> /etc/rstudio/rserver.conf && \
397425
echo auth-minimum-user-id=0 >> /etc/rstudio/rserver.conf && \
398426
echo "rsession-which-r={env_prefix}/bin/R" >> /etc/rstudio/rserver.conf && \
427+
echo "rsession-ld-library-path={env_prefix}/lib" >> /etc/rstudio/rserver.conf && \
399428
echo www-frame-origin=same >> /etc/rstudio/rserver.conf
400429
""",
401430
),

0 commit comments

Comments
 (0)