From b4b1ec3df8a1cbac998b142cfaddda6a2a1b0a3e Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 8 Jan 2023 20:08:35 -0700 Subject: [PATCH] Try another way to access packaged files --- app/build_containers.py | 7 +++++-- setup.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/build_containers.py b/app/build_containers.py index 87c92867..489af5d6 100644 --- a/app/build_containers.py +++ b/app/build_containers.py @@ -25,6 +25,7 @@ from decouple import config import subprocess import click import importlib +from pathlib import Path from .util import include_exclude_check # TODO: find a place for this @@ -43,9 +44,10 @@ def command(ctx, include, exclude): dry_run = ctx.obj.dry_run local_stack = ctx.obj.local_stack - # See: https://stackoverflow.com/a/20885799/1701505 + # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure from . import data - container_build_dir = importlib.resources.path(data, "container-build") + container_build_dir = Path(__file__).absolute().parent.joinpath("data", "container-build") + print(f"dir is: {container_build_dir}") if local_stack: dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")] @@ -59,6 +61,7 @@ def command(ctx, include, exclude): if not os.path.isdir(dev_root_path): print('Dev root directory doesn\'t exist, creating') + # See: https://stackoverflow.com/a/20885799/1701505 with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file: containers = container_list_file.read().splitlines() diff --git a/setup.py b/setup.py index 17d2ae35..94a2af53 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,8 @@ setup( install_requires=[requirements], python_requires='>=3.7', include_package_data=True, - package_data={'': ['data/*.txt']}, + # See: https://github.com/pypa/setuptools/issues/1806 + package_data={'': ['data/*', 'data/*/*', 'data/*/*/*']}, classifiers=[ "Programming Language :: Python :: 3.8", "Operating System :: OS Independent",