Skip to content

Commit

Permalink
Use importlib.metadata instead of pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Oct 10, 2023
1 parent 1167c29 commit a05e045
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]

steps:
- name: Checkout
Expand Down
10 changes: 8 additions & 2 deletions jupyverse_api/jupyverse_api/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import pkg_resources
import sys
from typing import List, Tuple

if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points

import rich_click as click
from asphalt.core.cli import run

Expand Down Expand Up @@ -70,9 +75,10 @@ def main(


def get_config(disable: Tuple[str, ...]) -> str:
group = entry_points().select(group="jupyverse.components")
jupyverse_components = [
ep.name
for ep in pkg_resources.iter_entry_points(group="jupyverse.components")
for ep in group
if ep.name not in disable
]

Expand Down
1 change: 1 addition & 0 deletions jupyverse_api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = [
"rich-click >=1.6.1,<2",
"asphalt >=4.11.0,<5",
"asphalt-web[fastapi] >=1.1.0,<2",
"importlib_metadata >= 4.4; python_version < '3.10'",
]
dynamic = ["version"]

Expand Down
12 changes: 9 additions & 3 deletions plugins/lab/fps_lab/routes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import json
import logging
import os
import sys
from glob import glob
from http import HTTPStatus
from pathlib import Path
from typing import List, Optional, Tuple

import json5 # type: ignore
import pkg_resources
if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points
from babel import Locale
from fastapi import Response, status
from fastapi.responses import FileResponse, RedirectResponse
Expand Down Expand Up @@ -80,7 +84,8 @@ async def get_translations(self, user: User):
"nativeName": native_name,
}
}
for ep in pkg_resources.iter_entry_points(group="jupyterlab.languagepack"):
group = entry_points().select(group="jupyterlab.languagepack")
for ep in group:
locale = Locale.parse(ep.name)
data[ep.name] = {
"displayName": display_name,
Expand All @@ -97,7 +102,8 @@ async def get_translation(
self.locale = language
return {}

for ep in pkg_resources.iter_entry_points(group="jupyterlab.languagepack"):
group = entry_points().select(group="jupyterlab.languagepack")
for ep in group:
if ep.name == language:
break
else:
Expand Down
1 change: 1 addition & 0 deletions plugins/lab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies = [
"babel",
"json5",
"jupyverse-api >=0.1.2,<1",
"importlib_metadata >= 4.4; python_version < '3.10'",
]
dynamic = [ "version",]
[[project.authors]]
Expand Down

0 comments on commit a05e045

Please sign in to comment.