Skip to content

Commit

Permalink
support.plugin: add python 3.8-3.9 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Oct 4, 2023
1 parent 17d59a8 commit cc2acdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ jobs:
YOSYS: yowasp-yosys
NEXTPNR_ICE40: yowasp-nextpnr-ice40
ICEPACK: yowasp-icepack
run: pdm run test
run: |
pdm run glasgow --help
pdm run test
build-firmware:
if: (github.event.ref == 'refs/heads/main' || github.event_name == 'pull_request') || github.repository != 'GlasgowEmbedded/glasgow'
Expand Down
13 changes: 8 additions & 5 deletions software/glasgow/support/plugin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import importlib.metadata
import packaging.requirements
import pathlib
import sysconfig
import textwrap
try:
import importlib_metadata # py3.9-
except ImportError:
import importlib.metadata as importlib_metadata


__all__ = ["PluginRequirementsUnmet", "PluginMetadata"]
Expand All @@ -24,8 +27,8 @@ def _unmet_requirements_in(requirements):
unmet_requirements = set()
for requirement in requirements:
try:
version = importlib.metadata.version(requirement.name)
except importlib.metadata.PackageNotFoundError:
version = importlib_metadata.version(requirement.name)
except importlib_metadata.PackageNotFoundError:
unmet_requirements.add(requirement)
continue
if not requirement.specifier.contains(version):
Expand Down Expand Up @@ -64,11 +67,11 @@ class PluginMetadata:

@classmethod
def get(cls, handle):
return cls(importlib.metadata.entry_points(group=cls.GROUP_NAME, name=handle)[0])
return cls(importlib_metadata.entry_points(group=cls.GROUP_NAME, name=handle)[0])

@classmethod
def all(cls):
return {ep.name: cls(ep) for ep in importlib.metadata.entry_points(group=cls.GROUP_NAME)}
return {ep.name: cls(ep) for ep in importlib_metadata.entry_points(group=cls.GROUP_NAME)}

def __init__(self, entry_point):
if entry_point.dist.name != "glasgow":
Expand Down
1 change: 1 addition & 0 deletions software/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
requires-python = "~=3.8"
dependencies = [
"packaging>=23",
"importlib_metadata; python_version<'3.10'",
"appdirs~=1.4",
"amaranth[builtin-yosys] @ git+https://github.com/amaranth-lang/amaranth.git",
"fx2>=0.11",
Expand Down

0 comments on commit cc2acdc

Please sign in to comment.