fail on unsupported Python
rather than warning (which users won't see) and building with the wrong version of Python
MODIFY
repo2docker/buildpacks/conda/__init__.py
repo2docker/buildpacks/conda/__init__.py
@@ -163,7 +163,7 @@ class CondaBuildPack(BaseImage):
frozen_name = "environment.lock"
pip_frozen_name = "requirements.txt"
if py_version:
- if self.py2:
+ if self.python_version == "2.7":
# python 2 goes in a different env
files[
"conda/environment.py-2.7.lock"
@@ -180,8 +180,8 @@ class CondaBuildPack(BaseImage):
if os.path.exists(os.path.join(HERE, py_frozen_name)):
frozen_name = py_frozen_name
pip_frozen_name = f"requirements.py-{py_version}.pip"
- if not frozen_name:
- self.log.warning(f"No frozen env for {py_version}\n")
+ else:
+ raise ValueError(f"Python version {py_version} is not supported!")
files[
"conda/" + frozen_name
] = self._nb_environment_file = "/tmp/env/environment.lock"

MODIFY
tests/unit/test_buildpack.py
tests/unit/test_buildpack.py
@@ -2,7 +2,7 @@ from os.path import join as pjoin
import pytest
from tempfile import TemporaryDirectory
-from repo2docker.buildpacks import LegacyBinderDockerBuildPack
+from repo2docker.buildpacks import LegacyBinderDockerBuildPack, PythonBuildPack
from repo2docker.utils import chdir
@@ -35,3 +35,13 @@ def test_legacy_on_repo_without_dockerfile():
with chdir(repodir):
bp = LegacyBinderDockerBuildPack()
assert not bp.detect()
+
+
+@pytest.mark.parametrize("python_version", ["2.6", "3.0", "4.10", "3.99"])
+def test_unsupported_python(tmpdir, python_version):
+ tmpdir.chdir()
+ bp = PythonBuildPack()
+ bp._python_version = python_version
+ assert bp.python_version == python_version
+ with pytest.raises(ValueError):
+ bp.render()

fail on unsupported Python

rather than warning (which users won't see) and building with the wrong version of Python