mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Switch from pkg_resources to importlib.metadata
Refs #2057, refs 852f5014
This commit is contained in:
parent
7d28ca1445
commit
c434ce03f9
2 changed files with 13 additions and 12 deletions
|
|
@ -11,7 +11,7 @@ import inspect
|
|||
from itsdangerous import BadSignature
|
||||
import json
|
||||
import os
|
||||
import pkg_resources
|
||||
import importlib.metadata
|
||||
import re
|
||||
import secrets
|
||||
import sys
|
||||
|
|
@ -921,9 +921,9 @@ class Datasette:
|
|||
if using_pysqlite3:
|
||||
for package in ("pysqlite3", "pysqlite3-binary"):
|
||||
try:
|
||||
info["pysqlite3"] = pkg_resources.get_distribution(package).version
|
||||
info["pysqlite3"] = importlib.metadata.version(package)
|
||||
break
|
||||
except pkg_resources.DistributionNotFound:
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
pass
|
||||
return info
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import importlib
|
||||
import importlib.metadata
|
||||
import importlib.resources
|
||||
import pluggy
|
||||
import pkg_resources
|
||||
import sys
|
||||
from . import hookspecs
|
||||
|
||||
|
|
@ -40,16 +41,16 @@ def get_plugins():
|
|||
templates_path = None
|
||||
if plugin.__name__ not in DEFAULT_PLUGINS:
|
||||
try:
|
||||
if pkg_resources.resource_isdir(plugin.__name__, "static"):
|
||||
static_path = pkg_resources.resource_filename(
|
||||
plugin.__name__, "static"
|
||||
if (importlib.resources.files(plugin.__name__) / "static").is_dir():
|
||||
static_path = str(
|
||||
importlib.resources.files(plugin.__name__) / "static"
|
||||
)
|
||||
if pkg_resources.resource_isdir(plugin.__name__, "templates"):
|
||||
templates_path = pkg_resources.resource_filename(
|
||||
plugin.__name__, "templates"
|
||||
if (importlib.resources.files(plugin.__name__) / "templates").is_dir():
|
||||
templates_path = str(
|
||||
importlib.resources.files(plugin.__name__) / "templates"
|
||||
)
|
||||
except (KeyError, ImportError):
|
||||
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
|
||||
except (TypeError, ModuleNotFoundError):
|
||||
# Caused by --plugins_dir= plugins
|
||||
pass
|
||||
plugin_info = {
|
||||
"name": plugin.__name__,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue