Skip to content

Commit f3db028

Browse files
authored
Merge pull request #50 from noahp/noahp/entrypoints
Use entrypoints for the scripts
2 parents a015a31 + ddc88d2 commit f3db028

File tree

10 files changed

+32
-14
lines changed

10 files changed

+32
-14
lines changed

intelhex/bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
# (c) Alexander Belchenko, 2007, 2009
33

44
# [2013/08] NOTE: This file is keeping for historical reasons.

intelhex/scripts/__init__.py

Whitespace-only changes.

scripts/bin2hex.py renamed to intelhex/scripts/bin2hex.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2008-2018 Alexander Belchenko
44
# All rights reserved.
@@ -37,7 +37,7 @@
3737

3838
VERSION = '2.3.0'
3939

40-
if __name__ == '__main__':
40+
def main():
4141
import getopt
4242
import os
4343
import sys
@@ -113,3 +113,6 @@
113113

114114
from intelhex import bin2hex
115115
sys.exit(bin2hex(fin, fout, offset))
116+
117+
if __name__ == '__main__':
118+
main()

scripts/hex2bin.py renamed to intelhex/scripts/hex2bin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2005-2018 Alexander Belchenko
44
# All rights reserved.
@@ -37,7 +37,7 @@
3737

3838
VERSION = '2.3.0'
3939

40-
if __name__ == '__main__':
40+
def main():
4141
import getopt
4242
import os
4343
import sys
@@ -130,3 +130,6 @@
130130

131131
from intelhex import hex2bin
132132
sys.exit(hex2bin(fin, fout, start, end, size, pad))
133+
134+
if __name__ == '__main__':
135+
main()

scripts/hex2dump.py renamed to intelhex/scripts/hex2dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2008-2018 Alexander Belchenko
44
# All rights reserved.

scripts/hexdiff.py renamed to intelhex/scripts/hexdiff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2011-2018 Alexander Belchenko
44
# All rights reserved.

scripts/hexinfo.py renamed to intelhex/scripts/hexinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2015 Andrew Fernandes <andrew@fernandes.org>
44
# All rights reserved.

scripts/hexmerge.py renamed to intelhex/scripts/hexmerge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2008-2018 Alexander Belchenko
44
# All rights reserved.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[wheel]
1+
[bdist_wheel]
22
universal = 1

setup.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22

33
# Copyright (c) 2008-2018, Alexander Belchenko
44
# All rights reserved.
@@ -35,7 +35,7 @@
3535

3636
"""Setup script for IntelHex."""
3737

38-
import sys, glob
38+
import os, sys, glob
3939
try:
4040
from setuptools import setup
4141
except ImportError:
@@ -46,12 +46,24 @@
4646

4747
LONG_DESCRIPTION = open('README.rst', 'r').read()
4848

49+
SCRIPT_MODULES = [os.path.splitext(x)[0] for x in glob.glob('intelhex/scripts/*')]
50+
51+
print(SCRIPT_MODULES)
52+
4953
METADATA = dict(
5054
name='intelhex',
5155
version=intelhex.__version__.version_str,
5256

53-
scripts=glob.glob('scripts/*'),
54-
packages=['intelhex'],
57+
# Include the scripts as a subpackage
58+
packages=['intelhex', 'intelhex.scripts'],
59+
60+
# For every script file, add an entrypoint
61+
entry_points={
62+
"console_scripts": [
63+
"{name}.py = intelhex.scripts.{name}:main".format(name=os.path.basename(x))
64+
for x in SCRIPT_MODULES
65+
]
66+
},
5567

5668
author='Alexander Belchenko',
5769
author_email='alexander.belchenko@gmail.com',

0 commit comments

Comments
 (0)