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
|
from itsdangerous import BadSignature
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import importlib.metadata
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -921,9 +921,9 @@ class Datasette:
|
||||||
if using_pysqlite3:
|
if using_pysqlite3:
|
||||||
for package in ("pysqlite3", "pysqlite3-binary"):
|
for package in ("pysqlite3", "pysqlite3-binary"):
|
||||||
try:
|
try:
|
||||||
info["pysqlite3"] = pkg_resources.get_distribution(package).version
|
info["pysqlite3"] = importlib.metadata.version(package)
|
||||||
break
|
break
|
||||||
except pkg_resources.DistributionNotFound:
|
except importlib.metadata.PackageNotFoundError:
|
||||||
pass
|
pass
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import importlib
|
import importlib
|
||||||
|
import importlib.metadata
|
||||||
|
import importlib.resources
|
||||||
import pluggy
|
import pluggy
|
||||||
import pkg_resources
|
|
||||||
import sys
|
import sys
|
||||||
from . import hookspecs
|
from . import hookspecs
|
||||||
|
|
||||||
|
|
@ -40,16 +41,16 @@ def get_plugins():
|
||||||
templates_path = None
|
templates_path = None
|
||||||
if plugin.__name__ not in DEFAULT_PLUGINS:
|
if plugin.__name__ not in DEFAULT_PLUGINS:
|
||||||
try:
|
try:
|
||||||
if pkg_resources.resource_isdir(plugin.__name__, "static"):
|
if (importlib.resources.files(plugin.__name__) / "static").is_dir():
|
||||||
static_path = pkg_resources.resource_filename(
|
static_path = str(
|
||||||
plugin.__name__, "static"
|
importlib.resources.files(plugin.__name__) / "static"
|
||||||
)
|
)
|
||||||
if pkg_resources.resource_isdir(plugin.__name__, "templates"):
|
if (importlib.resources.files(plugin.__name__) / "templates").is_dir():
|
||||||
templates_path = pkg_resources.resource_filename(
|
templates_path = str(
|
||||||
plugin.__name__, "templates"
|
importlib.resources.files(plugin.__name__) / "templates"
|
||||||
)
|
)
|
||||||
except (KeyError, ImportError):
|
except (TypeError, ModuleNotFoundError):
|
||||||
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
|
# Caused by --plugins_dir= plugins
|
||||||
pass
|
pass
|
||||||
plugin_info = {
|
plugin_info = {
|
||||||
"name": plugin.__name__,
|
"name": plugin.__name__,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue