From 661407c4f549f780c300dd4b5021b6691b697643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pal=CC=8Co?= Date: Mon, 5 Oct 2026 21:40:16 +0200 Subject: [PATCH] Skip KiCad plugin registration when run with python -m The package __init__ registers the pcbnew action plugin unless INTERACTIVE_HTML_BOM_CLI_MODE is set or argv[0] looks like the generate_interactive_bom script. With "python -m InteractiveHtmlBom.generate_interactive_bom" argv[0] is still "-m" while the package is imported, so it imported .ecad.kicad and failed with ModuleNotFoundError: pcbnew on systems without KiCad, breaking CLI use for EasyEDA, Eagle/Fusion and generic JSON files. Co-Authored-By: Claude Opus 5.5 --- InteractiveHtmlBom/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InteractiveHtmlBom/__init__.py b/InteractiveHtmlBom/__init__.py index f171a41f..33c9ac08 100644 --- a/InteractiveHtmlBom/__init__.py +++ b/InteractiveHtmlBom/__init__.py @@ -43,8 +43,11 @@ def callback(_): top_tb.Realize() +# sys.argv[0] is '-m' while this package is imported by +# "python -m InteractiveHtmlBom.generate_interactive_bom" if (not os.environ.get('INTERACTIVE_HTML_BOM_CLI_MODE', False) and - not os.path.basename(sys.argv[0]).startswith('generate_interactive_bom')): + not os.path.basename(sys.argv[0]).startswith('generate_interactive_bom') and + sys.argv[0] != '-m'): from .ecad.kicad import InteractiveHtmlBomPlugin plugin = InteractiveHtmlBomPlugin()