diff --git a/intelhex/bench.py b/intelhex/bench.py index df48447..7586e2c 100644 --- a/intelhex/bench.py +++ b/intelhex/bench.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # (c) Alexander Belchenko, 2007, 2009 # [2013/08] NOTE: This file is keeping for historical reasons. diff --git a/intelhex/scripts/__init__.py b/intelhex/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/bin2hex.py b/intelhex/scripts/bin2hex.py similarity index 98% rename from scripts/bin2hex.py rename to intelhex/scripts/bin2hex.py index ae474b3..6a2545a 100755 --- a/scripts/bin2hex.py +++ b/intelhex/scripts/bin2hex.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2008-2018 Alexander Belchenko # All rights reserved. @@ -37,7 +37,7 @@ VERSION = '2.3.0' -if __name__ == '__main__': +def main(): import getopt import os import sys @@ -113,3 +113,6 @@ from intelhex import bin2hex sys.exit(bin2hex(fin, fout, offset)) + +if __name__ == '__main__': + main() diff --git a/scripts/hex2bin.py b/intelhex/scripts/hex2bin.py similarity index 99% rename from scripts/hex2bin.py rename to intelhex/scripts/hex2bin.py index f84f703..9533837 100755 --- a/scripts/hex2bin.py +++ b/intelhex/scripts/hex2bin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2005-2018 Alexander Belchenko # All rights reserved. @@ -37,7 +37,7 @@ VERSION = '2.3.0' -if __name__ == '__main__': +def main(): import getopt import os import sys @@ -130,3 +130,6 @@ from intelhex import hex2bin sys.exit(hex2bin(fin, fout, start, end, size, pad)) + +if __name__ == '__main__': + main() diff --git a/scripts/hex2dump.py b/intelhex/scripts/hex2dump.py similarity index 99% rename from scripts/hex2dump.py rename to intelhex/scripts/hex2dump.py index 70a7c33..364fe1f 100755 --- a/scripts/hex2dump.py +++ b/intelhex/scripts/hex2dump.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2008-2018 Alexander Belchenko # All rights reserved. diff --git a/scripts/hexdiff.py b/intelhex/scripts/hexdiff.py similarity index 99% rename from scripts/hexdiff.py rename to intelhex/scripts/hexdiff.py index b903324..8acb58b 100755 --- a/scripts/hexdiff.py +++ b/intelhex/scripts/hexdiff.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2011-2018 Alexander Belchenko # All rights reserved. diff --git a/scripts/hexinfo.py b/intelhex/scripts/hexinfo.py similarity index 99% rename from scripts/hexinfo.py rename to intelhex/scripts/hexinfo.py index 207863c..02b7402 100755 --- a/scripts/hexinfo.py +++ b/intelhex/scripts/hexinfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2015 Andrew Fernandes # All rights reserved. diff --git a/scripts/hexmerge.py b/intelhex/scripts/hexmerge.py similarity index 99% rename from scripts/hexmerge.py rename to intelhex/scripts/hexmerge.py index e18cf65..8be98e8 100755 --- a/scripts/hexmerge.py +++ b/intelhex/scripts/hexmerge.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2008-2018 Alexander Belchenko # All rights reserved. diff --git a/setup.cfg b/setup.cfg index 9ed9ac5..14536a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ -[wheel] +[bdist_wheel] universal = 1 diff --git a/setup.py b/setup.py index 9f1df0d..ae4f207 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2008-2018, Alexander Belchenko # All rights reserved. @@ -35,7 +35,7 @@ """Setup script for IntelHex.""" -import sys, glob +import os, sys, glob try: from setuptools import setup except ImportError: @@ -46,12 +46,24 @@ LONG_DESCRIPTION = open('README.rst', 'r').read() +SCRIPT_MODULES = [os.path.splitext(x)[0] for x in glob.glob('intelhex/scripts/*')] + +print(SCRIPT_MODULES) + METADATA = dict( name='intelhex', version=intelhex.__version__.version_str, - scripts=glob.glob('scripts/*'), - packages=['intelhex'], + # Include the scripts as a subpackage + packages=['intelhex', 'intelhex.scripts'], + + # For every script file, add an entrypoint + entry_points={ + "console_scripts": [ + "{name}.py = intelhex.scripts.{name}:main".format(name=os.path.basename(x)) + for x in SCRIPT_MODULES + ] + }, author='Alexander Belchenko', author_email='alexander.belchenko@gmail.com',