66import sys
77# Add ../ to the path
88# Works if this script is executed without installing the module
9- script_dir = os .path .dirname (os .path .abspath (os .path .realpath (__file__ )))
10- sys .path .insert (0 , os .path .dirname (script_dir ))
11- # Pretend we are part of a module
12- # Avoids: ImportError: attempted relative import with no known parent package
13- __package__ = os .path .basename (script_dir )
14- __import__ (__package__ )
9+ try :
10+ import InteractiveHtmlBom
11+ except ImportError :
12+ script_dir = os .path .dirname (os .path .abspath (os .path .realpath (__file__ )))
13+ sys .path .insert (0 , os .path .dirname (script_dir ))
14+ # Pretend we are part of a module
15+ # Avoids: ImportError: attempted relative import with no known parent package
16+ __package__ = os .path .basename (script_dir )
17+ __import__ (__package__ )
1518
1619
1720# python 2 and 3 compatibility hack
@@ -34,11 +37,18 @@ def main():
3437 elif hasattr (wx , "DisableAsserts" ):
3538 wx .DisableAsserts ()
3639
37- from .core import ibom
38- from .core .config import Config
39- from .ecad import get_parser_by_extension
40- from .version import version
41- from .errors import (ExitCodes , ParsingException , exit_error )
40+ try :
41+ from .core import ibom
42+ from .core .config import Config
43+ from .ecad import get_parser_by_extension
44+ from .version import version
45+ from .errors import (ExitCodes , ParsingException , exit_error )
46+ except ImportError :
47+ from InteractiveHtmlBom .core import ibom
48+ from InteractiveHtmlBom .core .config import Config
49+ from InteractiveHtmlBom .ecad import get_parser_by_extension
50+ from InteractiveHtmlBom .version import version
51+ from InteractiveHtmlBom .errors import (ExitCodes , ParsingException , exit_error )
4252
4353 parser = argparse .ArgumentParser (
4454 description = 'KiCad InteractiveHtmlBom plugin CLI.' ,
0 commit comments