From 73757486b8651f968eb3952bd840453d1ff17453 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Fri, 7 Mar 2025 09:35:15 -0700 Subject: [PATCH] Two cupid_webpage fixes 1. Depending on how your environment is configured, you either need to import util or cupid.util (and git_helper or cupid.git_helper); added try / except blocks for both imports 2. Don't update github_pages_dir to a realpath unless it is non-empty (want to keep default behavior of not doing anything if user doesn't specify -g option; I was getting RuntimeError: When specifying -g/--github-pages-dir, you must also provide -n/--name even when not specifying -g) --- cupid/cupid_webpage.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cupid/cupid_webpage.py b/cupid/cupid_webpage.py index 1bb7cb8..4e8d8f6 100755 --- a/cupid/cupid_webpage.py +++ b/cupid/cupid_webpage.py @@ -22,9 +22,18 @@ from urllib.parse import quote import click -from git_helper import GitHelper -from util import get_control_dict -from util import is_bad_env + +try: + from git_helper import GitHelper +except ModuleNotFoundError: + from cupid.git_helper import GitHelper + +try: + from util import get_control_dict + from util import is_bad_env +except ModuleNotFoundError: + from cupid.util import get_control_dict + from cupid.util import is_bad_env def github_pages_publish( @@ -149,8 +158,8 @@ def build(config_path, github_pages_dir, name, overwrite): control = get_control_dict(config_path) # Check and process arguments - github_pages_dir = os.path.realpath(github_pages_dir) if github_pages_dir: + github_pages_dir = os.path.realpath(github_pages_dir) github_pages_dir_thisversion, git_repo = github_pages_args( github_pages_dir, name,