From d73c473b192bdccfef633ac5e9f96106e64ac6f9 Mon Sep 17 00:00:00 2001 From: Dina Belova Date: Wed, 3 Jul 2013 17:49:34 +0400 Subject: [PATCH] Migrate to pbr. For ease of future source code maintenance by OpenStack developers, git-review is now adopting the same Python Build Reasonableness as used by current OpenStack projects. Closes-Bug: 1179007 Change-Id: I20427b51e84b90dcc1d870a547cdcc5240b4ff0e --- .gitignore | 7 ++++- .mailmap | 9 +++++++ AUTHORS | 9 ------- MANIFEST.in | 1 + git_review/__init__.py | 0 git-review => git_review/cmd.py | 11 +++++--- requirements.txt | 1 + setup.cfg | 28 +++++++++++++++++++ setup.py | 48 ++------------------------------- test-requirements.txt | 5 ++++ tox.ini | 13 ++++++--- 11 files changed, 69 insertions(+), 63 deletions(-) create mode 100644 .mailmap delete mode 100644 AUTHORS create mode 100644 git_review/__init__.py rename git-review => git_review/cmd.py (99%) create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 test-requirements.txt diff --git a/.gitignore b/.gitignore index 7e27b2c9..f75e8ea8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,10 @@ build dist git_review.egg-info MANIFEST +AUTHORS +ChangeLog .tox -requirements.txt +.venv +*.egg +*.egg-info +*.pyc diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..9757c069 --- /dev/null +++ b/.mailmap @@ -0,0 +1,9 @@ +# Format is: +# +# + +David Ostrovsky +David Ostrovsky +James E. Blair +James E. Blair +James E. Blair diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index e9d54cfe..00000000 --- a/AUTHORS +++ /dev/null @@ -1,9 +0,0 @@ -Monty Taylor -James E. Blair -Saggi Mizrahi -Kiall Mac Innes -Roan Kattouw -Antoine Musso -Yuriy Taraday -Pavel Sedlák -Ori Livneh diff --git a/MANIFEST.in b/MANIFEST.in index 8d4abe09..21636ab4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include README.rst include LICENSE include AUTHORS +include ChangeLog include HACKING.rst include git-review.1 include tox.ini diff --git a/git_review/__init__.py b/git_review/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/git-review b/git_review/cmd.py similarity index 99% rename from git-review rename to git_review/cmd.py index e7557f5b..1126a2bf 100755 --- a/git-review +++ b/git_review/cmd.py @@ -21,6 +21,7 @@ limitations under the License.""" import datetime import json import os +import pkg_resources import re import shlex import subprocess @@ -42,8 +43,6 @@ else: urlparse = urllib.parse.urlparse do_input = input -version = "1.23" - VERBOSE = False UPDATE = False CONFIGDIR = os.path.expanduser("~/.config/git-review") @@ -145,6 +144,12 @@ def run_command_exc(klazz, *argv, **env): return output +def get_version(): + requirement = pkg_resources.Requirement.parse('git-review') + provider = pkg_resources.get_provider(requirement) + return provider.version + + def git_directories(): """Determine (absolute git work directory path, .git subdirectory path).""" cmd = ("git", "rev-parse", "--show-toplevel", "--git-dir") @@ -1004,7 +1009,7 @@ def main(): help="Print the license and exit") parser.add_argument("--version", action="version", version='%s version %s' % - (os.path.split(sys.argv[0])[-1], version)) + (os.path.split(sys.argv[0])[-1], get_version())) parser.add_argument("branch", nargs="?") try: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..1352d5e6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +argparse diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..6c82bbaf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = git-review +summary = Tool to submit code to Gerrit +description-file = README.rst +license = Apache License (2.0) +classifiers = + Programming Language :: Python :: 2 + Programming Language :: Python :: 3 + Programming Language :: Python + Development Status :: 5 - Production/Stable + Environment :: Console + Environment :: OpenStack + Intended Audience :: Developers + Intended Audience :: Information Technology + License :: OSI Approved :: Apache Software License + Operating System :: OS Independent +keywords = git gerrit review +author = OpenStack +author-email = openstack-infra@lists.openstack.org +home-page = https://pypi.python.org/pypi/git-review + +[files] +packages = + git_review + +[entry_points] +console_scripts = + git-review = git_review.cmd:main diff --git a/setup.py b/setup.py index 2b1de917..ce12df35 100755 --- a/setup.py +++ b/setup.py @@ -14,52 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from distutils.command import install as du_install -import os.path import setuptools -from setuptools.command import install -import sys - -version = None -# version comes from git-review. -savename = __name__ -__name__ = "not-main" -exec(open("git-review").read()) -__name__ = savename -class git_review_install(install.install): - # Force single-version-externally-managed - # This puts the manpage in the right location (instead of buried - # in an egg) - def run(self): - return du_install.install.run(self) - -git_review_cmdclass = {'install': git_review_install} - -manpath = 'share/man' -if os.path.exists(os.path.join(sys.prefix, 'man')): - # This works around a bug with install where it expects every node - # in the relative data directory to be an actual directory, since at - # least Debian derivatives (and probably other platforms as well) - # like to symlink Unixish /usr/local/man to /usr/local/share/man. - manpath = 'man' - -setuptools.setup( - name='git-review', - version=version, - cmdclass=git_review_cmdclass, - description="Tool to submit code to Gerrit", - license='Apache License (2.0)', - classifiers=[ - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - ], - keywords='git gerrit review', - author='OpenStack, LLC.', - author_email='openstack@lists.launchpad.net', - url='https://launchpad.net/git-review', - scripts=['git-review'], - data_files=[(os.path.join(manpath, 'man1'), ['git-review.1'])], - install_requires=['argparse'], -) +setuptools.setup(setup_requires=['pbr>=0.5.21,<1.0'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..1410633e --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +hacking>=0.5.6,<0.6 +discover + +testrepository>=0.0.13 +testtools>=0.9.27 diff --git a/tox.ini b/tox.ini index a88a585b..9c61dd8d 100644 --- a/tox.ini +++ b/tox.ini @@ -2,11 +2,17 @@ envlist = py26,py27,pep8 [testenv] -setenv = VIRTUAL_ENV={envdir} +setenv = + VIRTUAL_ENV={envdir} + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C + +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt [testenv:pep8] -deps = argparse - hacking<0.6 commands = flake8 [testenv:sdist] @@ -19,4 +25,3 @@ commands = {posargs} ignore = E125 show-source = True exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build -filename = git-review,setup.py