fail on unsupported Python

rather than warning (which users won't see) and building with the wrong version of Python
pull/1184/head
Min RK 2022-09-06 10:22:27 +02:00
rodzic 7580a30314
commit 1841bf7130
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 809C6E46EAA899F4
2 zmienionych plików z 14 dodań i 4 usunięć

Wyświetl plik

@ -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"

Wyświetl plik

@ -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()