From ce393f083c70d6ea98bfdeb7bf35d91daeb56285 Mon Sep 17 00:00:00 2001 From: Mike Hendricks Date: Wed, 3 Jan 2024 16:11:11 -0800 Subject: [PATCH] Simplify __main__.py --- src/pyqt_tools/__main__.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/pyqt_tools/__main__.py b/src/pyqt_tools/__main__.py index a82faf720..ebce4e3c7 100644 --- a/src/pyqt_tools/__main__.py +++ b/src/pyqt_tools/__main__.py @@ -1,19 +1,12 @@ -""" Enables support for calling entrypoints using `python -m` or `pythonw -m`. -On windows using `pythonw -m pyqt6_tools designer` in a shortcut allows opening -QtDesigner without showing a command prompt window that stays open the entire -time that QtDesigner is open. +""" Enables support for calling entrypoints using `python -m`. + +Examples: + Launching PyQt6 designer: `python -m pyqt6_tools designer` + Launching PyQt5 designer: `python -m pyqt5_tools designer` """ -import importlib -import pathlib import sys +from . import entrypoints -if __name__ == "__main__": - # Relative imports don't work when called by `python -m ...`, get the name - # of the parent folder so we can import entrypoints from it. This is needed - # because the package name is not hard coded between PyQt versions. - module_name = pathlib.Path(__file__).parent.stem - entrypoints = importlib.import_module(f"{module_name}.entrypoints") - - sys.exit(entrypoints.main()) +sys.exit(entrypoints.main())