From f4833ddca562be0c71549161f183d8fb8449eee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A9nainn=20Woodsend?= Date: Tue, 19 Sep 2023 23:22:40 +0100 Subject: [PATCH] Support Alpine and Fedora pre-release/edge versions. --- polycotylus/__init__.py | 7 +++++-- polycotylus/_alpine.py | 10 ++++++++-- polycotylus/_completions/polycotylus.fish | 4 ++-- polycotylus/_fedora.py | 10 ++++++++++ polycotylus/_mirror.py | 2 +- tests/test_alpine.py | 8 ++++---- tests/test_fedora.py | 5 +++-- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/polycotylus/__init__.py b/polycotylus/__init__.py index 1617f7b..019f3aa 100644 --- a/polycotylus/__init__.py +++ b/polycotylus/__init__.py @@ -7,17 +7,20 @@ def machine(): from ._exceptions import PolycotylusUsageError from ._project import Project -from ._alpine import Alpine, Alpine317, Alpine318 +from ._alpine import Alpine, Alpine317, Alpine318, AlpineEdge from ._arch import Arch from ._manjaro import Manjaro -from ._fedora import Fedora, Fedora37, Fedora38 +from ._fedora import Fedora, Fedora37, Fedora38, Fedora39, Fedora40 from ._void import Void, VoidGlibc, VoidMusl from ._opensuse import OpenSUSE distributions = {i.name: i for i in (Alpine, Arch, Fedora, Manjaro, Void, OpenSUSE)} distributions["alpine:3.17"] = Alpine317 distributions["alpine:3.18"] = Alpine318 +distributions["alpine:edge"] = AlpineEdge distributions["fedora:37"] = Fedora37 distributions["fedora:38"] = Fedora38 +distributions["fedora:39"] = Fedora39 +distributions["fedora:40"] = Fedora40 distributions["void:glibc"] = VoidGlibc distributions["void:musl"] = VoidMusl diff --git a/polycotylus/_alpine.py b/polycotylus/_alpine.py index a555f88..b1b2a7a 100644 --- a/polycotylus/_alpine.py +++ b/polycotylus/_alpine.py @@ -114,8 +114,9 @@ def apkbuild(self): ) subpackages = [] from packaging.version import Version - if self.project.contains_py_files and Version(self.version) >= Version("v3.18"): - subpackages.append("$pkgname-pyc") + if self.project.contains_py_files: + if self.version == "edge" or Version(self.version) >= Version("v3.18"): + subpackages.append("$pkgname-pyc") if "custom" in license_names: subpackages.append("$pkgname-doc") if subpackages: @@ -286,3 +287,8 @@ class Alpine317(Alpine): Alpine318 = Alpine + + +class AlpineEdge(Alpine): + version = "edge" + image = "alpine:edge" diff --git a/polycotylus/_completions/polycotylus.fish b/polycotylus/_completions/polycotylus.fish index 90bddf3..a383a49 100644 --- a/polycotylus/_completions/polycotylus.fish +++ b/polycotylus/_completions/polycotylus.fish @@ -1,6 +1,6 @@ set -l distributions alpine arch fedora manjaro opensuse void -set -l alpine_variants alpine:3.17 alpine:3.18 -set -l fedora_variants fedora:37 fedora:38 +set -l alpine_variants alpine:3.17 alpine:3.18 alpine:edge +set -l fedora_variants fedora:37 fedora:38 fedora:39 fedora:40 set -l void_variants void:musl void:glibc set -l all_variants $distributions $alpine_variants $fedora_variants $void_variants set -l atomic_flags --completion --list-localizations --configure --presubmit-check diff --git a/polycotylus/_fedora.py b/polycotylus/_fedora.py index f519b3d..0a5607f 100644 --- a/polycotylus/_fedora.py +++ b/polycotylus/_fedora.py @@ -308,3 +308,13 @@ class Fedora37(Fedora): Fedora38 = Fedora + + +class Fedora39(Fedora): + version = "39" + image = "fedora:39" + + +class Fedora40(Fedora): + version = "40" + image = "fedora:40" diff --git a/polycotylus/_mirror.py b/polycotylus/_mirror.py index e87c156..97decfd 100644 --- a/polycotylus/_mirror.py +++ b/polycotylus/_mirror.py @@ -385,7 +385,7 @@ def opensuse_last_sync_time(self: RequestHandler): ["APKINDEX.tar.gz"], [], 8901, - r"sed -r -i 's|^.*/(v\d+\.\d+)/|http://0.0.0.0:8901/\1/|g' /etc/apk/repositories", + r"sed -r -i 's|^.*/(v\d+\.\d+\|edge)/|http://0.0.0.0:8901/\1/|g' /etc/apk/repositories", (_alpine_sync_time, _use_last_modified_header), r"(.+-)([^-]+-r\d+)(\.apk)", ), diff --git a/tests/test_alpine.py b/tests/test_alpine.py index 048c55c..6697fbc 100644 --- a/tests/test_alpine.py +++ b/tests/test_alpine.py @@ -11,7 +11,7 @@ from polycotylus import _docker, _exceptions, machine from polycotylus._project import Project from polycotylus._mirror import mirrors -from polycotylus._alpine import Alpine, Alpine317 +from polycotylus._alpine import Alpine, Alpine317, AlpineEdge import shared mirror = mirrors["alpine"] @@ -235,7 +235,7 @@ def _write_trove(trove): def test_kitchen_sink(monkeypatch): monkeypatch.setenv("SETUPTOOLS_SCM_PRETEND_VERSION", "1.2.3") all_apks = [] - for _Alpine in (Alpine, Alpine317): + for _Alpine in (Alpine, Alpine317, AlpineEdge): self = _Alpine(Project.from_root(shared.kitchen_sink)) self.generate() assert "pywin32-ctypes" not in self.apkbuild() @@ -246,7 +246,7 @@ def test_kitchen_sink(monkeypatch): container = _docker.run(installed, script) assert """🚀 🦄 "quoted" 'quoted again' $$$""" in container.output assert "license:\ncustom" in container.output - assert ("pyc" in apks) is (_Alpine is Alpine) + assert ("pyc" in apks) is (_Alpine is not Alpine317) all_apks.extend(apks.values()) with tarfile.open(apks["doc"]) as tar: @@ -257,7 +257,7 @@ def test_kitchen_sink(monkeypatch): for apk in all_apks: assert apk.exists() - assert len(set(all_apks)) == 5 + assert len(set(all_apks)) == 8 test_multiarch = shared.qemu(Alpine) diff --git a/tests/test_fedora.py b/tests/test_fedora.py index 2c76956..81ca535 100644 --- a/tests/test_fedora.py +++ b/tests/test_fedora.py @@ -11,7 +11,7 @@ from polycotylus import _docker, _exceptions from polycotylus._project import Project -from polycotylus._fedora import Fedora, Fedora37 +from polycotylus._fedora import Fedora, Fedora37, Fedora40 from polycotylus.__main__ import cli import shared @@ -65,7 +65,8 @@ def test_ubrotli(): self.test(packages["main"]) -def test_dumb_text_viewer(): +@pytest.mark.parametrize("Fedora", [Fedora37, Fedora40]) +def test_dumb_text_viewer(Fedora): self = Fedora(Project.from_root(shared.dumb_text_viewer)) self.generate() container = self.test(self.build()["main"])