From f39cb74ba840e10dc0aea5fbfed2cd08a4d8a3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20S=C3=B8ndergaard?= Date: Mon, 8 May 2023 09:18:28 +0200 Subject: [PATCH] Fix entrypoint loading on Py37 Closes #402. --- conda/meta.yaml | 8 ++++---- pyproject.toml | 2 +- src/gwf/utils.py | 13 ++++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index a7cc23e2..d5bad233 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,5 +1,5 @@ {% set name = "gwf" %} -{% set version = "2.0.0" %} +{% set version = "2.0.1" %} package: name: "{{ name|lower }}" @@ -20,13 +20,13 @@ requirements: - click - click-plugins - python>=3.7 - - importlib_metadata + - importlib_metadata>=4.6 # [py37] run: - attrs - click - click-plugins - python>=3.7 - - importlib_metadata + - importlib_metadata>=4.6 # [py37] test: imports: @@ -38,7 +38,7 @@ test: - gwf --version about: - home: http://gwf.app/ + home: https://gwf.app/ license: GNU General Public v3 (GPLv3) license_family: GPL3 summary: A flexible, pragmatic workflow tool. diff --git a/pyproject.toml b/pyproject.toml index 6b639d5f..08bdd6c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ "attrs", # Used to discover plugins and backends, see: # https://packaging.python.org/guides/creating-and-discovering-plugins/ - "importlib_metadata; python_version<'3.10'", + "importlib_metadata>4.6; python_version<'3.8'", ] [project.optional-dependencies] diff --git a/src/gwf/utils.py b/src/gwf/utils.py index d8abc64e..bacdd9d6 100644 --- a/src/gwf/utils.py +++ b/src/gwf/utils.py @@ -10,10 +10,10 @@ from functools import wraps from pathlib import Path -if sys.version_info < (3, 10): - from importlib_metadata import entry_points # noqa: E401 +if sys.version_info < (3, 8): + from importlib_metadata import entry_points as _entry_points # noqa: E401 else: - from importlib.metadata import entry_points # noqa: F401 + from importlib.metadata import entry_points as _entry_points # noqa: F401 import click @@ -22,6 +22,13 @@ logger = logging.getLogger(__name__) +def entry_points(group=None): + eps = _entry_points() + if group is None: + return eps + return eps[group] + + def is_valid_name(candidate): """Check whether `candidate` is a valid name for a target or workflow.""" return re.match(r"^[a-zA-Z_][a-zA-Z0-9._]*$", candidate) is not None