Skip to content

Commit

Permalink
patch use of deprecated apis
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Feb 21, 2024
1 parent 2e53474 commit f572905
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
29 changes: 29 additions & 0 deletions recipe/0000-use-py312-entry-point-group.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/jupyter_book/cli/pluggable.py b/jupyter_book/cli/pluggable.py
index 113608a..24dabd4 100644
--- a/jupyter_book/cli/pluggable.py
+++ b/jupyter_book/cli/pluggable.py
@@ -3,18 +3,18 @@ from typing import Any, Iterable, List, Set

import click

-try:
- from importlib import metadata
-except ImportError:
- import importlib_metadata as metadata
+if __import__("sys").version_info < (3, 10):
+ from importlib_metadata import entry_points
+else:
+ from importlib.metadata import entry_points


def get_entry_point_names(group: str) -> List[str]:
- return [ep.name for ep in metadata.entry_points().get(group, [])]
+ return [ep.name for ep in entry_points(group=group)]


def load_entry_point(group: str, name: str) -> Any:
- eps = [ep for ep in metadata.entry_points().get(group, []) if ep.name == name]
+ eps = [ep for ep in entry_points(group=group) if ep.name == name]
if not eps:
raise KeyError(f"Entry-point {group}:{name}")
return eps[0].load()
8 changes: 6 additions & 2 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "0.15.1" %}
{% set version = "1.0.0" %}
{% set min_python = "python >=3.9" %}

package:
Expand All @@ -8,14 +8,16 @@ package:
source:
url: https://pypi.io/packages/source/j/jupyter-book/jupyter_book-{{ version }}.tar.gz
sha256: 539c5d0493546200d9de27bd4b5f77eaea03115f8937f825d4ff82b3801a987e
patches:
- 0000-use-py312-entry-point-group.patch

build:
number: 0
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
entry_points:
- jb = jupyter_book.cli.main:main
- jupyter-book = jupyter_book.cli.main:main
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation

requirements:
host:
Expand All @@ -42,6 +44,8 @@ requirements:
- sphinx-thebe >=0.3,<1
- sphinx-togglebutton
- sphinxcontrib-bibtex >=2.5.0,<3
# dep added by patch
- importlib-metadata >=4.8.3

test:
imports:
Expand Down

0 comments on commit f572905

Please sign in to comment.