From 4d57f529c93e9074caa99796d3438bad1174fa73 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:36:49 +0100 Subject: [PATCH] Use entry_points instead of scripts in setup.py This allows a fine-grained control of the dependencies, because it generates a wrapper script that calls the specifiend function (i.e., main inside cheat/app.py) --- bin/cheat => cheat/app.py | 10 +++++++--- setup.py | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) rename bin/cheat => cheat/app.py (95%) diff --git a/bin/cheat b/cheat/app.py similarity index 95% rename from bin/cheat rename to cheat/app.py index 46af2a2..50fddea 100755 --- a/bin/cheat +++ b/cheat/app.py @@ -31,12 +31,13 @@ Options: """ # require the dependencies -from cheat import * -from cheat.utils import * +import sheet +import sheets +from utils import * from docopt import docopt -if __name__ == '__main__': +def main(): # parse the command-line options options = docopt(__doc__, version='cheat 2.1.3') @@ -59,3 +60,6 @@ if __name__ == '__main__': # print the cheatsheet else: print(colorize(sheet.read(options['']))) + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 26f3f02..91aa692 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,11 @@ setup( package_data = { 'cheat.cheatsheets': ['*'], }, - scripts = ['bin/cheat'], + entry_points = { + 'console_scripts': [ + 'cheat = cheat.app:main', + ], + }, install_requires = [ 'docopt >= 0.6.1', 'pygments >= 1.6.0',