Skip to content

Commit

Permalink
Support Alpine and Fedora pre-release/edge versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoodsend committed Sep 19, 2023
1 parent fdf7438 commit f4833dd
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
7 changes: 5 additions & 2 deletions polycotylus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions polycotylus/_alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -286,3 +287,8 @@ class Alpine317(Alpine):


Alpine318 = Alpine


class AlpineEdge(Alpine):
version = "edge"
image = "alpine:edge"
4 changes: 2 additions & 2 deletions polycotylus/_completions/polycotylus.fish
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions polycotylus/_fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion polycotylus/_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
),
Expand Down
8 changes: 4 additions & 4 deletions tests/test_alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit f4833dd

Please sign in to comment.