mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
importlib_resources for Python < 3.9, refs #2057
This commit is contained in:
parent
947520c1fe
commit
b0d0a0e5de
2 changed files with 11 additions and 5 deletions
|
|
@ -1,10 +1,15 @@
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
import importlib.resources
|
|
||||||
import os
|
import os
|
||||||
import pluggy
|
import pluggy
|
||||||
import sys
|
import sys
|
||||||
from . import hookspecs
|
from . import hookspecs
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
import importlib.resources as importlib_resources
|
||||||
|
else:
|
||||||
|
import importlib_resources
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_PLUGINS = (
|
DEFAULT_PLUGINS = (
|
||||||
"datasette.publish.heroku",
|
"datasette.publish.heroku",
|
||||||
"datasette.publish.cloudrun",
|
"datasette.publish.cloudrun",
|
||||||
|
|
@ -61,13 +66,13 @@ 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 (importlib.resources.files(plugin.__name__) / "static").is_dir():
|
if (importlib_resources.files(plugin.__name__) / "static").is_dir():
|
||||||
static_path = str(
|
static_path = str(
|
||||||
importlib.resources.files(plugin.__name__) / "static"
|
importlib_resources.files(plugin.__name__) / "static"
|
||||||
)
|
)
|
||||||
if (importlib.resources.files(plugin.__name__) / "templates").is_dir():
|
if (importlib_resources.files(plugin.__name__) / "templates").is_dir():
|
||||||
templates_path = str(
|
templates_path = str(
|
||||||
importlib.resources.files(plugin.__name__) / "templates"
|
importlib_resources.files(plugin.__name__) / "templates"
|
||||||
)
|
)
|
||||||
except (TypeError, ModuleNotFoundError):
|
except (TypeError, ModuleNotFoundError):
|
||||||
# Caused by --plugins_dir= plugins
|
# Caused by --plugins_dir= plugins
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -48,6 +48,7 @@ setup(
|
||||||
"Jinja2>=2.10.3",
|
"Jinja2>=2.10.3",
|
||||||
"hupper>=1.9",
|
"hupper>=1.9",
|
||||||
"httpx>=0.20",
|
"httpx>=0.20",
|
||||||
|
'importlib_resources>=1.3.1; python_version < "3.9"',
|
||||||
"pint>=0.9",
|
"pint>=0.9",
|
||||||
"pluggy>=1.0",
|
"pluggy>=1.0",
|
||||||
"uvicorn>=0.11",
|
"uvicorn>=0.11",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue