From 3150878ad8ec6ee5a7a451b50182f45cb699c044 Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 12 Dec 2023 13:50:30 -0500 Subject: [PATCH] add resources symlink this allows editable installs to find asdf_standard.resources during an editable install (via importlib.resources.files) --- MANIFEST.in | 3 +++ src/asdf_standard/integration.py | 9 +-------- src/asdf_standard/resources | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 MANIFEST.in create mode 120000 src/asdf_standard/resources diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..781a8c14 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +# Exclude the symlink included to allow +# importlib.resources to work for editable installs +exclude src/*/resources diff --git a/src/asdf_standard/integration.py b/src/asdf_standard/integration.py index 8981fe56..3b90b06f 100644 --- a/src/asdf_standard/integration.py +++ b/src/asdf_standard/integration.py @@ -1,5 +1,4 @@ import sys -from pathlib import Path if sys.version_info < (3, 9): import importlib_resources @@ -10,13 +9,7 @@ def get_resource_mappings(): - resources_root = importlib_resources.files(asdf_standard) / "resources" - if not resources_root.is_dir(): - # In an editable install, the resources directory will exist off the - # repository root: - resources_root = Path(__file__).absolute().parent.parent.parent / "resources" - if not resources_root.is_dir(): - raise RuntimeError("Missing resources directory") + resources_root = importlib_resources.files("asdf_standard") / "resources" return [ asdf_standard.DirectoryResourceMapping( diff --git a/src/asdf_standard/resources b/src/asdf_standard/resources new file mode 120000 index 00000000..bc764151 --- /dev/null +++ b/src/asdf_standard/resources @@ -0,0 +1 @@ +../../resources \ No newline at end of file