From 4332bff3f500f062e7e06edccf0da5a9d9379d79 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 11 May 2013 15:35:37 -0400 Subject: [PATCH] Migrate to pbr for build pbr is the libification of what was openstack.common.setup. If provides the build information in a delcarative form, instead of as executable python code, which works around the chicken and egg problem of needing setup libraries present to run setup, but needing to run setup to tell if you need setup libraries. One of the features that comes along with this is versioning based on git tags. If the current revision is a signed git tag, then that is the version of the package. If it is not, the version is equal to the most recent git tag, plus a commit count, plus a git sha (similar to git describe, but scrubbed for python version rules compliance) pbr updates are also part of the upcoming automation around ensuring global requirements stay in sync. Closes-Bug: #1179007 Change-Id: Ia473960be7e8aa44f09d48cea72ed3c8845f82fa --- requirements.txt | 1 + setup.cfg | 90 ++++++++++++++++++++++++++++ setup.py | 110 +++------------------------------- swift/__init__.py | 31 ++++++---- test/unit/common/test_init.py | 38 ------------ 5 files changed, 116 insertions(+), 154 deletions(-) delete mode 100644 test/unit/common/test_init.py diff --git a/requirements.txt b/requirements.txt index 558b6e815f..70fbca17d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +pbr>=0.5.21,<1.0 dnspython>=1.10.0 eventlet>=0.9.15 greenlet>=0.3.1 diff --git a/setup.cfg b/setup.cfg index 656f082c9e..81b739f9d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,93 @@ +[metadata] +name = swift +summary = OpenStack Object Storage +description-file = + README.md +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Development Status :: 5 - Production/Stable + Environment :: OpenStack + 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.6 + Programming Language :: Python :: 2.7 + +[pbr] +skip_authors = True +skip_changelog = True + +[files] +packages = + swift +scripts = + bin/swift-account-audit + bin/swift-account-auditor + bin/swift-account-reaper + bin/swift-account-replicator + bin/swift-account-server + bin/swift-bench + bin/swift-bench-client + bin/swift-config + bin/swift-container-auditor + bin/swift-container-replicator + bin/swift-container-server + bin/swift-container-sync + bin/swift-container-updater + bin/swift-dispersion-populate + bin/swift-dispersion-report + bin/swift-drive-audit + bin/swift-form-signature + bin/swift-get-nodes + bin/swift-init + bin/swift-object-auditor + bin/swift-object-expirer + bin/swift-object-info + bin/swift-object-replicator + bin/swift-object-server + bin/swift-object-updater + bin/swift-oldies + bin/swift-orphans + bin/swift-proxy-server + bin/swift-recon + bin/swift-recon-cron + bin/swift-ring-builder + bin/swift-temp-url + +[entry_points] +paste.app_factory = + proxy = swift.proxy.server:app_factory + object = swift.obj.server:app_factory + container = swift.container.server:app_factory + account = swift.account.server:app_factory + +paste.filter_factory = + healthcheck = swift.common.middleware.healthcheck:filter_factory + crossdomain = swift.common.middleware.crossdomain:filter_factory + memcache = swift.common.middleware.memcache:filter_factory + ratelimit = swift.common.middleware.ratelimit:filter_factory + cname_lookup = swift.common.middleware.cname_lookup:filter_factory + catch_errors = swift.common.middleware.catch_errors:filter_factory + domain_remap = swift.common.middleware.domain_remap:filter_factory + staticweb = swift.common.middleware.staticweb:filter_factory + tempauth = swift.common.middleware.tempauth:filter_factory + keystoneauth = swift.common.middleware.keystoneauth:filter_factory + recon = swift.common.middleware.recon:filter_factory + tempurl = swift.common.middleware.tempurl:filter_factory + formpost = swift.common.middleware.formpost:filter_factory + name_check = swift.common.middleware.name_check:filter_factory + bulk = swift.common.middleware.bulk:filter_factory + container_quotas = swift.common.middleware.container_quotas:filter_factory + account_quotas = swift.common.middleware.account_quotas:filter_factory + proxy_logging = swift.common.middleware.proxy_logging:filter_factory + slo = swift.common.middleware.slo:filter_factory + list_endpoints = swift.common.middleware.list_endpoints:filter_factory + [build_sphinx] all_files = 1 build-dir = doc/build diff --git a/setup.py b/setup.py index 6c4c2328c1..2a0786a8b2 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2010-2012 OpenStack, LLC. +#!/usr/bin/env python +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,105 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import setup, find_packages +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools -from swift import __canonical_version__ as version - - -name = 'swift' - - -with open('requirements.txt', 'r') as f: - requires = [x.strip() for x in f if x.strip()] - - -setup( - name=name, - version=version, - description='Swift', - license='Apache License (2.0)', - author='OpenStack, LLC.', - author_email='openstack-admins@lists.launchpad.net', - url='https://launchpad.net/swift', - packages=find_packages(exclude=['test', 'bin']), - test_suite='nose.collector', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Environment :: No Input/Output (Daemon)', - 'Environment :: OpenStack', - ], - install_requires=requires, - scripts=[ - 'bin/swift-account-audit', - 'bin/swift-account-auditor', - 'bin/swift-account-reaper', - 'bin/swift-account-replicator', - 'bin/swift-account-server', - 'bin/swift-bench', - 'bin/swift-bench-client', - 'bin/swift-config', - 'bin/swift-container-auditor', - 'bin/swift-container-replicator', - 'bin/swift-container-server', - 'bin/swift-container-sync', - 'bin/swift-container-updater', - 'bin/swift-dispersion-populate', - 'bin/swift-dispersion-report', - 'bin/swift-drive-audit', - 'bin/swift-form-signature', - 'bin/swift-get-nodes', - 'bin/swift-init', - 'bin/swift-object-auditor', - 'bin/swift-object-expirer', - 'bin/swift-object-info', - 'bin/swift-object-replicator', - 'bin/swift-object-server', - 'bin/swift-object-updater', - 'bin/swift-oldies', - 'bin/swift-orphans', - 'bin/swift-proxy-server', - 'bin/swift-recon', - 'bin/swift-recon-cron', - 'bin/swift-ring-builder', - 'bin/swift-temp-url', - ], - entry_points={ - 'paste.app_factory': [ - 'proxy=swift.proxy.server:app_factory', - 'object=swift.obj.server:app_factory', - 'container=swift.container.server:app_factory', - 'account=swift.account.server:app_factory', - ], - 'paste.filter_factory': [ - 'healthcheck=swift.common.middleware.healthcheck:filter_factory', - 'crossdomain=swift.common.middleware.crossdomain:filter_factory', - 'memcache=swift.common.middleware.memcache:filter_factory', - 'ratelimit=swift.common.middleware.ratelimit:filter_factory', - 'cname_lookup=swift.common.middleware.cname_lookup:filter_factory', - 'catch_errors=swift.common.middleware.catch_errors:filter_factory', - 'domain_remap=swift.common.middleware.domain_remap:filter_factory', - 'staticweb=swift.common.middleware.staticweb:filter_factory', - 'tempauth=swift.common.middleware.tempauth:filter_factory', - 'keystoneauth=swift.common.middleware.keystoneauth:filter_factory', - 'recon=swift.common.middleware.recon:filter_factory', - 'tempurl=swift.common.middleware.tempurl:filter_factory', - 'formpost=swift.common.middleware.formpost:filter_factory', - 'name_check=swift.common.middleware.name_check:filter_factory', - 'bulk=swift.common.middleware.bulk:filter_factory', - 'container_quotas=swift.common.middleware.container_quotas:' - 'filter_factory', - 'account_quotas=swift.common.middleware.account_quotas:' - 'filter_factory', - 'proxy_logging=swift.common.middleware.proxy_logging:' - 'filter_factory', - 'slo=swift.common.middleware.slo:filter_factory', - 'list_endpoints=swift.common.middleware.list_endpoints:' - 'filter_factory', - ], - }, -) +setuptools.setup( + setup_requires=['pbr>=0.5.21,<1.0'], + pbr=True) diff --git a/swift/__init__.py b/swift/__init__.py index 573313a2f5..0951da7e4b 100644 --- a/swift/__init__.py +++ b/swift/__init__.py @@ -1,16 +1,21 @@ -class Version(object): - def __init__(self, canonical_version, final): - self.canonical_version = canonical_version - self.final = final +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# 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. - @property - def pretty_version(self): - if self.final: - return self.canonical_version - else: - return '%s-dev' % (self.canonical_version,) +import pbr.version -_version = Version('1.9.2', False) -__version__ = _version.pretty_version -__canonical_version__ = _version.canonical_version +_version_info = pbr.version.VersionInfo('swift') +__version__ = _version_info.release_string() +__canonical_version__ = _version_info.version_string() diff --git a/test/unit/common/test_init.py b/test/unit/common/test_init.py deleted file mode 100644 index ee79b6dceb..0000000000 --- a/test/unit/common/test_init.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2010-2012 OpenStack, LLC. -# -# 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 re -import unittest -import swift - - -class TestVersioning(unittest.TestCase): - def test_canonical_version_is_clean(self): - """Ensure that a non-clean canonical_version never happens""" - pattern = re.compile('^\d+(\.\d+)*$') - self.assertTrue(pattern.match(swift.__canonical_version__) is not None) - - def test_canonical_version_equals_version_for_final(self): - version = swift.Version('7.8.9', True) - self.assertEquals(version.pretty_version, '7.8.9') - self.assertEquals(version.canonical_version, '7.8.9') - - def test_version_has_dev_suffix_for_non_final(self): - version = swift.Version('7.8.9', False) - self.assertEquals(version.pretty_version, '7.8.9-dev') - self.assertEquals(version.canonical_version, '7.8.9') - -if __name__ == '__main__': - unittest.main()