Skip to content

Commit

Permalink
version info
Browse files Browse the repository at this point in the history
  • Loading branch information
hotkeysoft committed Jul 8, 2020
1 parent 7e23340 commit 5d6d896
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
17 changes: 17 additions & 0 deletions chiplabel/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
# _version.py
__version__ = '1.0.0a1'
__app__ = 'chip_label'
__author__ = 'Dominic Thibodeau'
__author_email__ = '[email protected]'
__description__ = 'Chip Label Generator'
__url__ = 'https://github.com/hotkeysoft/chiplabel_py'
__year__ = 2020

def print_version_info():
v = f'{__app__} {__description__} version {__version__}'
print(v)
print('-'*len(v))
print(f'{__year__} {__author__} {__author_email__}')
print(__url__)

5 changes: 5 additions & 0 deletions chiplabel/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def parse_args(args=None):
help='list all chips in package',
action='store_true'
)
action_group.add_argument(
'--version',
help="print version info",
action="store_true"
)

parser.add_argument(
'-i', '--input',
Expand Down
7 changes: 6 additions & 1 deletion chiplabel/chip_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import logging
import os
import sys
from PIL import Image
from .args import parse_args
from .chip import Chip
from .chip_list import ChipList
from .chip_printer import ChipPrinter
from .chip_grid_printer import ChipGridPrinter
from ._version import print_version_info

log = logging.getLogger()

Expand Down Expand Up @@ -63,6 +65,10 @@ def format(self, record):
def main(argv):
args = parse_args(argv[1:])

if args.version:
print_version_info()
return

# Configure logging
old_loglevel = log.level
handler = logging.StreamHandler()
Expand Down Expand Up @@ -101,7 +107,6 @@ def main(argv):
log.setLevel(old_loglevel)

if __name__ == '__main__':
import sys
MIN_PYTHON = (3, 6)
if sys.version_info < MIN_PYTHON:
sys.exit("Python %s.%s or later is required.\n" % MIN_PYTHON)
Expand Down
36 changes: 21 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import setuptools
from distutils.util import convert_path

with open("README.md", "r") as fh:
long_description = fh.read()
with open("README.md", "r") as readme_file:
long_description = readme_file.read()

version_info = {}
ver_path = convert_path('chiplabel/_version.py')
with open(ver_path) as ver_file:
exec(ver_file.read(), version_info)

setuptools.setup(
name="chiplabel",
version="1.0.0a1",
author="Dominic Thibodeau",
author_email="[email protected]",
description="Chip label generator",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/hotkeysoft/chiplabel_py",
name = "chiplabel",
version = version_info['__version__'],
author = version_info['__author__'],
author_email = version_info['__author_email__'],
description = version_info['__description__'],
long_description = long_description,
long_description_content_type = "text/markdown",
url = version_info['__url__'],
packages=setuptools.find_packages(include=['chiplabel']),
include_package_data = True,
package_data={'chiplabel': ['fonts/*', 'chips/*']},
Expand All @@ -26,11 +32,11 @@
"Programming Language :: Python :: 3",
"Topic :: Utilities",
],
python_requires='>=3.6',
install_requires=['Pillow', 'PyYAML'],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
entry_points={
python_requires = '>=3.6',
install_requires = ['Pillow', 'PyYAML'],
setup_requires = ['pytest-runner'],
tests_require = ['pytest'],
entry_points = {
'console_scripts': ['chip_label=chiplabel.__main__:main']
},
)

0 comments on commit 5d6d896

Please sign in to comment.