From 7a71108c60e2b53638d424da2841c963aec053e6 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 3 May 2014 10:35:36 -0700 Subject: [PATCH] Add a pbr compatible setup Add a setup.cfg and setup.py and fill in those files so that gertty can be installed easily. Adjust gertty.py to have a main function that can be referenced as a console entrypoint during installation. Also adjusted a bunch of imports that were failing after installation occurred (but now they should not fail since they correctly reference the gertty module namespace). Change-Id: I532ced51583b26300ba9a2efb97f8e41bc69ec8d --- gertty/{gertty.py => app.py} | 21 +++++++++++++-------- gertty/view/change.py | 10 +++++----- gertty/view/change_list.py | 6 +++--- gertty/view/diff.py | 2 +- gertty/view/project_list.py | 8 ++++---- requirements.txt | 1 + setup.cfg | 32 ++++++++++++++++++++++++++++++++ setup.py | 20 ++++++++++++++++++++ 8 files changed, 79 insertions(+), 21 deletions(-) rename gertty/{gertty.py => app.py} (97%) create mode 100644 setup.cfg create mode 100755 setup.py diff --git a/gertty/gertty.py b/gertty/app.py similarity index 97% rename from gertty/gertty.py rename to gertty/app.py index 563321f..5f80a2b 100644 --- a/gertty/gertty.py +++ b/gertty/app.py @@ -20,12 +20,12 @@ import threading import urwid -import db -import config -import gitrepo -import mywid -import sync -import view.project_list +from gertty import db +from gertty import config +from gertty import gitrepo +from gertty import mywid +from gertty import sync +from gertty.view import project_list as view_project_list palette=[('reversed', 'default,standout', ''), ('header', 'white,bold', 'dark blue'), @@ -130,7 +130,7 @@ class App(object): self.screens = [] self.status = StatusHeader(self) self.header = urwid.AttrMap(self.status, 'header') - screen = view.project_list.ProjectListView(self) + screen = view_project_list.ProjectListView(self) self.status.update(title=screen.title) self.loop = urwid.MainLoop(screen, palette=palette, unhandled_input=self.unhandledInput) @@ -221,7 +221,8 @@ class App(object): return gitrepo.Repo(self.config.url+'p/'+project_name, local_path) -if __name__ == '__main__': + +def main(): parser = argparse.ArgumentParser( description='Console client for Gerrit Code Review.') parser.add_argument('-d', dest='debug', action='store_true', @@ -233,3 +234,7 @@ if __name__ == '__main__': args = parser.parse_args() g = App(args.server, args.debug, args.no_sync) g.run() + + +if __name__ == '__main__': + main() diff --git a/gertty/view/change.py b/gertty/view/change.py index d9c0017..571f6ad 100644 --- a/gertty/view/change.py +++ b/gertty/view/change.py @@ -16,10 +16,10 @@ import datetime import urwid -import gitrepo -import mywid -import sync -import view.diff +from gertty import gitrepo +from gertty import mywid +from gertty import sync +from gertty.view import diff as view_diff class ReviewDialog(urwid.WidgetWrap): signals = ['save', 'cancel'] @@ -384,4 +384,4 @@ This Screen return r def diff(self, revision_key): - self.app.changeScreen(view.diff.DiffView(self.app, revision_key)) + self.app.changeScreen(view_diff.DiffView(self.app, revision_key)) diff --git a/gertty/view/change_list.py b/gertty/view/change_list.py index 5805e81..3ec1282 100644 --- a/gertty/view/change_list.py +++ b/gertty/view/change_list.py @@ -14,8 +14,8 @@ import urwid -import mywid -import view.change +from gertty import mywid +from gertty.view import change as view_change class ChangeRow(urwid.Button): change_focus_map = {None: 'reversed', @@ -139,4 +139,4 @@ This Screen return super(ChangeListView, self).keypress(size, key) def onSelect(self, button, change_key): - self.app.changeScreen(view.change.ChangeView(self.app, change_key)) + self.app.changeScreen(view_change.ChangeView(self.app, change_key)) diff --git a/gertty/view/diff.py b/gertty/view/diff.py index b42ed2b..1f7267c 100644 --- a/gertty/view/diff.py +++ b/gertty/view/diff.py @@ -17,7 +17,7 @@ import logging import urwid -import mywid +from gertty import mywid class LineContext(object): def __init__(self, old_revision_key, new_revision_key, diff --git a/gertty/view/project_list.py b/gertty/view/project_list.py index 97125fa..42fbc45 100644 --- a/gertty/view/project_list.py +++ b/gertty/view/project_list.py @@ -14,9 +14,9 @@ import urwid -import mywid -import sync -import view.change_list +from gertty import mywid +from gertty import sync +from gertty.view import change_list as view_change_list class ProjectRow(urwid.Button): project_focus_map = {None: 'reversed', @@ -113,7 +113,7 @@ This Screen return ret def onSelect(self, button, project_key): - self.app.changeScreen(view.change_list.ChangeListView(self.app, project_key)) + self.app.changeScreen(view_change_list.ChangeListView(self.app, project_key)) def keypress(self, size, key): if key=='l': diff --git a/requirements.txt b/requirements.txt index 5dfe3f7..d46cb63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ GitPython>=0.3.2.RC1 python-dateutil requests ordereddict +pbr>=0.6,!=0.7,<1.0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c7bf973 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,32 @@ +[metadata] +name = gertty +summary = Gertty is a console-based interface to the Gerrit Code Review system. +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Topic :: Utilities + Intended Audience :: Developers + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 2.6 +keywords = gerrit console urwid review + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[files] +packages = + gertty + +[entry_points] +console_scripts = + gertty = gertty.app:main diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..186fa00 --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import setuptools + +setuptools.setup( + setup_requires=['pbr'], + pbr=True)