Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use importlib.metadata instead of pkg_resources #357

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 8 additions & 6 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,11 +75,8 @@ def main(


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

config = ["component:\n type: jupyverse\n components:\n"]
for component in jupyverse_components:
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
13 changes: 10 additions & 3 deletions plugins/lab/fps_lab/routes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
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 +85,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 +103,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
Loading