diff --git a/src/yacfg/cli/yacfg_cli.py b/src/yacfg/cli/yacfg_cli.py index 0e57790e..fbbd663c 100755 --- a/src/yacfg/cli/yacfg_cli.py +++ b/src/yacfg/cli/yacfg_cli.py @@ -1,19 +1,16 @@ +#! /usr/bin/env -S python3 -sP + import logging import os import sys -from .. import NAME, __version__, logger_settings +from yacfg import NAME, __version__, logger_settings from yacfg.cli.cli_arguments import boolize, parse_key_value_list, parser -from ..config_data import RenderOptions -from ..exceptions import GenerationError, ProfileError, TemplateError -from ..output import ( - export_tuning_variables, - new_profile, - new_profile_rendered, - new_template, -) -from ..query import list_profiles, list_templates -from ..yacfg import generate +from yacfg.config_data import RenderOptions +from yacfg.exceptions import GenerationError, ProfileError, TemplateError +from yacfg.output import export_tuning_variables, new_profile, new_profile_rendered, new_template +from yacfg.query import list_profiles, list_templates +from yacfg.yacfg import generate logger_settings.config_console_logger() @@ -107,10 +104,10 @@ def run(self, args=None): self.error(str(exc), 0) if ( - options.new_profile - or options.new_profile_static - or options.export_tuning - or options.new_template + options.new_profile + or options.new_profile_static + or options.export_tuning + or options.new_template ): sys.exit(0) @@ -148,3 +145,7 @@ def error(msg: str, ecode: int = 2) -> None: def main(): app = CommandLineApp() app.run() + + +if __name__ == '__main__': + main() diff --git a/src/yacfg_batch/yacfg_batch_cli.py b/src/yacfg_batch/yacfg_batch_cli.py old mode 100644 new mode 100755 index 41b8159c..c220769b --- a/src/yacfg_batch/yacfg_batch_cli.py +++ b/src/yacfg_batch/yacfg_batch_cli.py @@ -1,13 +1,24 @@ +#! /usr/bin/env -S python3 -sP + from __future__ import print_function import logging +import pathlib import sys +# `from yacfg_batch import ...` may target both src/yacfg/yacfg_batch/__init__.py +# and src/yacfg/yacfg_batch/yacfg_batch.py (which is on sys.path when running +# this file directly). Remove the undesirable sys.path entry to prevent `ImportError`s. +try: + sys.path.remove(str(pathlib.Path(__file__).resolve().parent)) +except ValueError: + pass + from yacfg import NAME, logger_settings -from . import __version__ -from .cli_arguments import parser -from .yacfg_batch import generate +from yacfg_batch import __version__ +from yacfg_batch.cli_arguments import parser +from yacfg_batch.yacfg_batch import generate logger_settings.config_console_logger()