convert command-line executables to entry_points console_scripts, best practice according to Python Packaging Authority (eases testing, etc)

This commit is contained in:
Noah Levitt 2016-06-27 14:46:42 -05:00
parent 84767af0f6
commit 9df2ce0fbe
3 changed files with 32 additions and 32 deletions

View File

@ -1,7 +0,0 @@
#!/usr/bin/env python
from __future__ import absolute_import
import warcprox.main
warcprox.main.main()

View File

@ -49,8 +49,9 @@ try:
except: except:
deps.append('futures') deps.append('futures')
setuptools.setup(name='warcprox', setuptools.setup(
version='2.0.dev12', name='warcprox',
version='2.0.dev13',
description='WARC writing MITM HTTP/S proxy', description='WARC writing MITM HTTP/S proxy',
url='https://github.com/internetarchive/warcprox', url='https://github.com/internetarchive/warcprox',
author='Noah Levitt', author='Noah Levitt',
@ -62,7 +63,12 @@ setuptools.setup(name='warcprox',
tests_require=['requests>=2.0.1', 'pytest'], # >=2.0.1 for https://github.com/kennethreitz/requests/pull/1636 tests_require=['requests>=2.0.1', 'pytest'], # >=2.0.1 for https://github.com/kennethreitz/requests/pull/1636
cmdclass = {'test': PyTest}, cmdclass = {'test': PyTest},
test_suite='warcprox.tests', test_suite='warcprox.tests',
scripts=['bin/dump-anydbm', 'bin/warcprox'], entry_points={
'console_scripts': [
'warcprox=warprox.main:main',
'dump-anydbm=warcprox.dump_anydbm:main',
],
},
zip_safe=False, zip_safe=False,
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',

View File

@ -1,30 +1,28 @@
#!/usr/bin/env python #!/usr/bin/env python
# '''
# dump-anydbm - dumps contents of dbm file to stdout dump-anydbm - dumps contents of dbm file to stdout
#
# Copyright (C) 2013-2016 Internet Archive
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
"""
Dump contents of database to stdout. Database can be any file that the anydbm Dump contents of database to stdout. Database can be any file that the anydbm
module can read. Included with warcprox because it's useful for inspecting a module can read. Included with warcprox because it's useful for inspecting a
deduplication database or a playback index database, but it is a generic tool. deduplication database or a playback index database, but it is a generic tool.
"""
Copyright (C) 2013-2016 Internet Archive
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
'''
try: try:
import dbm import dbm
@ -40,6 +38,9 @@ import sys
import os.path import os.path
if __name__ == "__main__": if __name__ == "__main__":
main()
def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:
sys.stderr.write("usage: {} DBM_FILE\n".format(sys.argv[0])) sys.stderr.write("usage: {} DBM_FILE\n".format(sys.argv[0]))
exit(1) exit(1)