From 04a3049162ee6fc99f0633eff4c1539dedd5c546 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 17 Jan 2023 22:25:04 -0700 Subject: [PATCH] Make code compatible with Pyton 3.8 --- app/setup_repositories.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/setup_repositories.py b/app/setup_repositories.py index 8f00ae0f..1969c29c 100644 --- a/app/setup_repositories.py +++ b/app/setup_repositories.py @@ -23,6 +23,7 @@ import git from tqdm import tqdm import click import importlib.resources +from pathlib import Path import yaml from .util import include_exclude_check @@ -100,8 +101,10 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches_file): all_repos = repository_list_file.read().splitlines() if stack: - resource_data_dir = importlib.resources.files(data) - with importlib.resources.as_file(resource_data_dir.joinpath(f"stacks/{stack}/stack.yml")) as stack_file_path: + # In order to be compatible with Python 3.8 we need to use this hack to get the path: + # See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure + stack_file_path = Path(__file__).absolute().parent.joinpath("data", "stacks", stack, "stack.yml") + with stack_file_path: stack_config = yaml.safe_load(open(stack_file_path, "r")) print(f"stack is: {stack_config}")