From 76a91ce3587517d92fc6d60825008702ebf80a45 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Thu, 8 Jan 2015 23:54:12 +0100 Subject: [PATCH 1/5] Use setuptools insted of distutils. Distutils is old and basic, setuptools is the current preferred way. See https://python-packaging-user-guide.readthedocs.org/en/latest/current.html --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a747c6d..09e17ed 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup import os setup( From fdbc8909cc481fbf337240b994ab1e68e5e11487 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Thu, 8 Jan 2015 23:58:35 +0100 Subject: [PATCH 2/5] Use find_packages from setuptools to identify packages --- setup.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 09e17ed..b3f5034 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages import os setup( @@ -12,11 +12,7 @@ setup( 'administrators of options for commands that they use frequently, but not ' 'frequently enough to remember.', url = 'https://github.com/chrisallenlane/cheat', - packages = [ - 'cheat', - 'cheat.cheatsheets', - 'cheat.test', - ], + packages = find_packages(), package_data = { 'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f] }, From 69f91e0cf42f846fb0829a7c9ffa35653c3dd66f Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:08:38 +0100 Subject: [PATCH 3/5] Exploit setuptools package_data to include cheats --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b3f5034..b9207dc 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ from setuptools import setup, find_packages -import os setup( name = 'cheat', @@ -14,7 +13,7 @@ setup( url = 'https://github.com/chrisallenlane/cheat', packages = find_packages(), package_data = { - 'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f] + 'cheat.cheatsheets': ['*'], }, scripts = ['bin/cheat'], install_requires = [ From 5caa8fed38c16d897a5ecc1c7f5490e87e269682 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:22:57 +0100 Subject: [PATCH 4/5] Improve setup.py description --- setup.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b9207dc..26f3f02 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,13 @@ +"""cheat + ~~~~~~~~ + + cheat allows you to create and view interactive cheatsheets on the + command-line. It was designed to help remind *nix system administrators of + options for commands that they use frequently, but not frequently enough + to remember. + :license: GPL3 +""" + from setuptools import setup, find_packages setup( @@ -6,10 +16,8 @@ setup( author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', - description = 'cheat allows you to create and view interactive cheatsheets ' - 'on the command-line. It was designed to help remind *nix system ' - 'administrators of options for commands that they use frequently, but not ' - 'frequently enough to remember.', + description = 'cheat allows you to create and view interactive cheatsheets on the command-line', + long_description = __doc__, url = 'https://github.com/chrisallenlane/cheat', packages = find_packages(), package_data = { From 4d57f529c93e9074caa99796d3438bad1174fa73 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:36:49 +0100 Subject: [PATCH 5/5] 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',