Skip to content

Commit b6bf515

Browse files
committed
Drop support for Python 3.8.
This also adds the recently released Python 3.13 to CI.
1 parent 41762f1 commit b6bf515

File tree

10 files changed

+19
-40
lines changed

10 files changed

+19
-40
lines changed

.github/workflows/main.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ jobs:
1111
strategy:
1212
matrix:
1313
python-version:
14-
- '3.8'
1514
- '3.9'
1615
- '3.10'
1716
- '3.11'
1817
- '3.12'
19-
- 'pypy-3.8'
18+
- '3.13'
2019
- 'pypy-3.9'
2120
- 'pypy-3.10'
2221
allow-failure:
2322
- false
2423
include:
25-
- python-version: '3.13-dev'
24+
- python-version: '3.14-dev'
2625
allow-failure: true
2726
continue-on-error: ${{ matrix.allow-failure }}
2827
name: 'test (${{ matrix.python-version }})'

amaranth/_toolchain/yosys.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@
44
import subprocess
55
import warnings
66
import pathlib
7-
from importlib import metadata as importlib_metadata
8-
try:
9-
from importlib import resources as importlib_resources
10-
try:
11-
importlib_resources.files # py3.9+ stdlib
12-
except AttributeError:
13-
import importlib_resources # py3.8- shim
14-
except ImportError:
15-
importlib_resources = None
7+
import importlib.metadata
8+
import importlib.resources
169

1710
from . import has_tool, require_tool
1811

@@ -109,23 +102,21 @@ class _BuiltinYosys(YosysBinary):
109102

110103
@classmethod
111104
def available(cls):
112-
if importlib_metadata is None or importlib_resources is None:
113-
return False
114105
try:
115-
importlib_metadata.version(cls.YOSYS_PACKAGE)
106+
importlib.metadata.version(cls.YOSYS_PACKAGE)
116107
return True
117-
except importlib_metadata.PackageNotFoundError:
108+
except importlib.metadata.PackageNotFoundError:
118109
return False
119110

120111
@classmethod
121112
def version(cls):
122-
version = importlib_metadata.version(cls.YOSYS_PACKAGE)
113+
version = importlib.metadata.version(cls.YOSYS_PACKAGE)
123114
match = re.match(r"^(\d+)\.(\d+)\.(?:\d+)(?:\.(\d+))?(?:\.post(\d+))?", version)
124115
return (int(match[1]), int(match[2]), int(match[3] or 0), int(match[4] or 0))
125116

126117
@classmethod
127118
def data_dir(cls):
128-
return importlib_resources.files(cls.YOSYS_PACKAGE) / "share"
119+
return importlib.resources.files(cls.YOSYS_PACKAGE) / "share"
129120

130121
@classmethod
131122
def run(cls, args, stdin="", *, ignore_warnings=False, src_loc_at=0):

amaranth/back/rtlil.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable
1+
from collections.abc import Iterable
22
from contextlib import contextmanager
33
import io
44

amaranth/build/res.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ def add_clock_constraint(self, clock, period=None, frequency=None):
311311
clocks[clock] = frequency
312312

313313
def iter_signal_clock_constraints(self):
314-
for signal, frequency in self._clocks.items():
315-
yield signal, frequency
314+
yield from self._clocks.items()
316315

317316
def iter_port_clock_constraints(self):
318-
for port, frequency in self._io_clocks.items():
319-
yield port, frequency
317+
yield from self._io_clocks.items()

amaranth/hdl/_ir.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def __init__(self, netlist: _nir.Netlist, design: Design, *, all_undef_to_ff=Fal
706706
# SignalDict from Signal to dict from (module index, ClockDomain | None) to NetlistDriver
707707
self.drivers = _ast.SignalDict()
708708
self.io_ports: dict[_ast.IOPort, int] = {}
709-
self.rhs_cache: dict[int, Tuple[_nir.Value, bool, _ast.Value]] = {}
709+
self.rhs_cache: dict[int, tuple[_nir.Value, bool, _ast.Value]] = {}
710710
self.matches_cache = {}
711711
self.priority_match_cache = {}
712712
self.fragment_module_idx: dict[Fragment, int] = {}
@@ -817,7 +817,7 @@ def unify_shapes_bitwise(self,
817817
operand_b = self.extend(operand_b, signed_b, shape.width)
818818
return (operand_a, operand_b, shape.signed)
819819

820-
def emit_rhs(self, module_idx: int, value: _ast.Value) -> Tuple[_nir.Value, bool]:
820+
def emit_rhs(self, module_idx: int, value: _ast.Value) -> tuple[_nir.Value, bool]:
821821
"""Emits a RHS value, returns a tuple of (value, is_signed)"""
822822
try:
823823
result, signed, value = self.rhs_cache[id(value)]

amaranth/hdl/_nir.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Iterable, Any
1+
from typing import Any
2+
from collections.abc import Iterable
23
import enum
34

45
from ._ast import SignalDict

amaranth/lib/enum.py

-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class EnumType(ShapeCastable, py_enum.EnumMeta):
2929
can be specified by passing the ``view_class=`` keyword argument when creating the enum class.
3030
"""
3131

32-
# TODO: remove this shim once py3.8 support is dropped
33-
@classmethod
34-
def __prepare__(metacls, name, bases, shape=None, view_class=None, **kwargs):
35-
return super().__prepare__(name, bases, **kwargs)
36-
3732
def __new__(metacls, name, bases, namespace, shape=None, view_class=None, **kwargs):
3833
if shape is not None:
3934
shape = Shape.cast(shape)

amaranth/lib/meta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ def _extract_schemas(package, *, base_uri, path="schema/"):
141141
f"Schema $id {schema['$id']} must be {base_uri}/{relative_path}"
142142

143143
schema_filename.parent.mkdir(parents=True, exist_ok=True)
144-
with open(pathlib.Path(path) / relative_path, "wt") as schema_file:
144+
with open(pathlib.Path(path) / relative_path, "w") as schema_file:
145145
json.dump(schema, schema_file, indent=2)
146146
print(f"Extracted {schema['$id']} to {schema_filename}")

docs/install.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ System requirements
2323
2424
.. |yosys-version| replace:: 0.40 (or newer)
2525

26-
Amaranth HDL requires Python 3.8; it works on CPython_ 3.8 (or newer), and works faster on PyPy3.8_ 7.3.7 (or newer). Installation requires pip_ 23.0 (or newer).
26+
Amaranth HDL requires Python 3.9; it works on CPython_ 3.9 (or newer), and works faster on PyPy3.9_ 7.3.7 (or newer). Installation requires pip_ 23.0 (or newer).
2727

2828
For most workflows, Amaranth requires Yosys_ |yosys-version|. A `compatible version of Yosys <amaranth-yosys_>`_ is distributed via PyPI_ for most popular platforms, so it is usually not necessary to install Yosys separately.
2929

@@ -34,7 +34,7 @@ Synthesizing, placing and routing an Amaranth design for an FPGA requires the FP
3434
.. TODO: Link to FPGA family docs here
3535
3636
.. _CPython: https://www.python.org/
37-
.. _PyPy3.8: https://www.pypy.org/
37+
.. _PyPy3.9: https://www.pypy.org/
3838
.. _pip: https://pip.pypa.io/en/stable/
3939
.. _Yosys: https://yosyshq.net/yosys/
4040
.. _amaranth-yosys: https://pypi.org/project/amaranth-yosys/

pyproject.toml

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ readme = "README.md"
1313
authors = [{name = "Amaranth HDL contributors"}]
1414
license = { text = "BSD-2-clause" }
1515

16-
requires-python = "~=3.8"
16+
requires-python = "~=3.9"
1717
dependencies = [
18-
"importlib_resources; python_version<'3.9'", # for amaranth._toolchain.yosys
1918
"jschon~=0.11.1", # for amaranth.lib.meta
2019
"pyvcd>=0.2.2,<0.5", # for amaranth.sim.pysim
2120
"Jinja2~=3.0", # for amaranth.build
@@ -47,10 +46,6 @@ amaranth-rpc = "amaranth.rpc:main"
4746
requires = ["pdm-backend~=2.3.0"]
4847
build-backend = "pdm.backend"
4948

50-
[tool.pdm]
51-
# Remove this once we no longer support Python 3.8.
52-
ignore_package_warnings = ["sphinx*", "alabaster"]
53-
5449
[tool.pdm.build]
5550
# If amaranth 0.3 is checked out with git (e.g. as a part of a persistent editable install or
5651
# a git worktree cached by tools like poetry), it can have an empty `nmigen` directory left over,

0 commit comments

Comments
 (0)