Skip to content

Commit 8a1cba2

Browse files
committed
adding packaging tweaks to script
1 parent 5915a24 commit 8a1cba2

3 files changed

Lines changed: 39 additions & 11 deletions

File tree

InteractiveHtmlBom/generate_interactive_bom.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
import 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.',

setup.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[bumpversion]
2+
current_version = '2.9.0'
3+
LAST_TAG = 'v2.9.0'
4+
commit = True
5+
tag = True
6+
7+
[bumpversion:file:InteractiveHtmlBom/version.py]
8+
search = LAST_TAG = 'v{current_version}'
9+
replace = LAST_TAG = 'v{new_version}'
10+
11+
[bdist_wheel]
12+
universal = 1
13+
14+
[flake8]
15+
exclude = docs

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from setuptools import setup
2+
3+
setup()

0 commit comments

Comments
 (0)