From 66aac71cf07cbc14c5196cc1c144b9965fec7d2c Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 9 Apr 2024 18:20:58 +0200 Subject: [PATCH] Update FastAPI-Users v13.0.0 (#395) * Update FastAPI-Users v13.0.0 * Test Python 3.12 * Drop pkg_resources for entry points --- .github/workflows/test.yml | 4 ++-- jupyverse_api/jupyverse_api/cli.py | 9 +++++++-- jupyverse_api/pyproject.toml | 1 + plugins/auth/pyproject.toml | 2 +- plugins/lab/fps_lab/routes.py | 11 ++++++++--- plugins/lab/pyproject.toml | 1 + plugins/yjs/fps_yjs/ywidgets/widgets.py | 9 +++++++-- plugins/yjs/pyproject.toml | 1 + 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce82a606..091561e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' cache: 'pip' - name: Install hatch run: | @@ -43,7 +43,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 diff --git a/jupyverse_api/jupyverse_api/cli.py b/jupyverse_api/jupyverse_api/cli.py index 913bd5c4..20dd8a2f 100644 --- a/jupyverse_api/jupyverse_api/cli.py +++ b/jupyverse_api/jupyverse_api/cli.py @@ -1,9 +1,14 @@ +import sys from typing import List, Tuple -import pkg_resources import rich_click as click from asphalt.core.cli import run +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points + @click.command() # type: ignore @click.option( @@ -72,7 +77,7 @@ def main( def get_config(disable: Tuple[str, ...]) -> str: jupyverse_components = [ ep.name - for ep in pkg_resources.iter_entry_points(group="jupyverse.components") + for ep in entry_points(group="jupyverse.components") if ep.name not in disable ] diff --git a/jupyverse_api/pyproject.toml b/jupyverse_api/pyproject.toml index bb4d0e43..a8168883 100644 --- a/jupyverse_api/pyproject.toml +++ b/jupyverse_api/pyproject.toml @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ + "importlib_metadata >=3.6; python_version<'3.10'", "pydantic >=2,<3", "fastapi >=0.95.0,<1", "rich-click >=1.6.1,<2", diff --git a/plugins/auth/pyproject.toml b/plugins/auth/pyproject.toml index 50e4fde5..f6c48d7a 100644 --- a/plugins/auth/pyproject.toml +++ b/plugins/auth/pyproject.toml @@ -10,7 +10,7 @@ dynamic = ["version"] requires-python = ">=3.8" dependencies = [ "aiosqlite", - "fastapi-users[sqlalchemy,oauth] >=12,<13", + "fastapi-users[sqlalchemy,oauth] >=13.0.0,<14.0.0", "jupyverse-api >=0.1.2,<1", ] diff --git a/plugins/lab/fps_lab/routes.py b/plugins/lab/fps_lab/routes.py index 339579e9..3f68f844 100644 --- a/plugins/lab/fps_lab/routes.py +++ b/plugins/lab/fps_lab/routes.py @@ -1,13 +1,13 @@ 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 from babel import Locale from fastapi import Response, status from fastapi.responses import FileResponse, RedirectResponse @@ -19,6 +19,11 @@ from jupyverse_api.jupyterlab import JupyterLabConfig from jupyverse_api.lab import Lab +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points + logger = logging.getLogger("lab") @@ -79,7 +84,7 @@ async def get_translations(self, user: User): "nativeName": native_name, } } - for ep in pkg_resources.iter_entry_points(group="jupyterlab.languagepack"): + for ep in entry_points(group="jupyterlab.languagepack"): locale = Locale.parse(ep.name) data[ep.name] = { "displayName": display_name, @@ -96,7 +101,7 @@ async def get_translation( self.locale = language return {} - for ep in pkg_resources.iter_entry_points(group="jupyterlab.languagepack"): + for ep in entry_points(group="jupyterlab.languagepack"): if ep.name == language: break else: diff --git a/plugins/lab/pyproject.toml b/plugins/lab/pyproject.toml index 094eecff..04b4229b 100644 --- a/plugins/lab/pyproject.toml +++ b/plugins/lab/pyproject.toml @@ -8,6 +8,7 @@ description = "An FPS plugin for the JupyterLab/Notebook API" keywords = ["jupyter", "server", "fastapi", "plugins"] requires-python = ">=3.8" dependencies = [ + "importlib_metadata >=3.6; python_version<'3.10'", "babel", "json5", "jupyverse-api >=0.1.2,<1", diff --git a/plugins/yjs/fps_yjs/ywidgets/widgets.py b/plugins/yjs/fps_yjs/ywidgets/widgets.py index b080a524..52eeae03 100644 --- a/plugins/yjs/fps_yjs/ywidgets/widgets.py +++ b/plugins/yjs/fps_yjs/ywidgets/widgets.py @@ -1,6 +1,6 @@ +import sys from typing import Any -import pkg_resources from pycrdt import TransactionEvent try: @@ -15,6 +15,11 @@ except ImportError: ypywidgets_installed = False +if sys.version_info < (3, 10): + from importlib_metadata import entry_points +else: + from importlib.metadata import entry_points + Widgets: Any @@ -22,7 +27,7 @@ class Widgets: # type: ignore def __init__(self): self.ydocs = { - ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="ypywidgets") + ep.name: ep.load() for ep in entry_points(group="ypywidgets") } self.widgets = {} diff --git a/plugins/yjs/pyproject.toml b/plugins/yjs/pyproject.toml index d17210e0..94ac7f81 100644 --- a/plugins/yjs/pyproject.toml +++ b/plugins/yjs/pyproject.toml @@ -8,6 +8,7 @@ description = "An FPS plugin for the Yjs API" keywords = [ "jupyter", "server", "fastapi", "plugins" ] requires-python = ">=3.8" dependencies = [ + "importlib_metadata >=3.6; python_version<'3.10'", "pycrdt >=0.8.16,<0.9.0", "jupyverse-api >=0.1.2,<1", ]