Skip to content

Commit

Permalink
Fix entrypoint loading on Py37
Browse files Browse the repository at this point in the history
Closes #402.
  • Loading branch information
dansondergaard committed May 8, 2023
1 parent 6355b60 commit f39cb74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "gwf" %}
{% set version = "2.0.0" %}
{% set version = "2.0.1" %}

package:
name: "{{ name|lower }}"
Expand All @@ -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:
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 10 additions & 3 deletions src/gwf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit f39cb74

Please sign in to comment.