From a549b74ebfa666c1c3f76d415dcf7440bf09737c Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Wed, 18 Mar 2015 20:25:49 -0500 Subject: [PATCH] Entrypoints for commands Use entrypoints for keystone-all and keystone-manage. This makes keystone consistent with other projects that already use entry points, e.g., nova. Change-Id: Ib8d1a30d9b31d515dd5256896e24ae7b327fff6e --- keystone/cmd/__init__.py | 0 bin/keystone-all => keystone/cmd/all.py | 9 ++++++--- bin/keystone-manage => keystone/cmd/manage.py | 9 ++++++--- setup.cfg | 7 ++++--- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 keystone/cmd/__init__.py rename bin/keystone-all => keystone/cmd/all.py (82%) mode change 100755 => 100644 rename bin/keystone-manage => keystone/cmd/manage.py (85%) mode change 100755 => 100644 diff --git a/keystone/cmd/__init__.py b/keystone/cmd/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bin/keystone-all b/keystone/cmd/all.py old mode 100755 new mode 100644 similarity index 82% rename from bin/keystone-all rename to keystone/cmd/all.py index 3b0038207a..c583accd0f --- a/bin/keystone-all +++ b/keystone/cmd/all.py @@ -18,9 +18,11 @@ import os import sys -# If ../keystone/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)lib/python... +# If ../../keystone/__init__.py exists, add ../../ to Python search path, so +# that it will override what happens to be installed in +# /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(__file__), + os.pardir, os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, @@ -32,5 +34,6 @@ if os.path.exists(os.path.join(possible_topdir, from keystone.server import eventlet as eventlet_server -if __name__ == '__main__': +# entry point. +def main(): eventlet_server.run(possible_topdir) diff --git a/bin/keystone-manage b/keystone/cmd/manage.py old mode 100755 new mode 100644 similarity index 85% rename from bin/keystone-manage rename to keystone/cmd/manage.py index 360c49a4f8..31bf772129 --- a/bin/keystone-manage +++ b/keystone/cmd/manage.py @@ -17,9 +17,11 @@ import os import sys -# If ../keystone/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)lib/python... +# If ../../keystone/__init__.py exists, add ../../ to Python search path, so +# that it will override what happens to be installed in +# /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, @@ -31,7 +33,8 @@ from keystone import cli from keystone.common import environment -if __name__ == '__main__': +# entry point. +def main(): environment.use_stdlib() dev_conf = os.path.join(possible_topdir, diff --git a/setup.cfg b/setup.cfg index e646480cf3..be1b666ce9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,9 +20,6 @@ classifier = [files] packages = keystone -scripts = - bin/keystone-all - bin/keystone-manage [global] setup-hooks = @@ -63,6 +60,10 @@ warnerrors = True #autodoc_tree_root = ./keystone [entry_points] +console_scripts = + keystone-all = keystone.cmd.all:main + keystone-manage = keystone.cmd.manage:main + oslo.config.opts = keystone = keystone.common.config:list_opts keystone.notifications = keystone.notifications:list_opts