diff --git a/README.md b/README.md index 47f0494c8..79a7229ca 100644 --- a/README.md +++ b/README.md @@ -200,9 +200,9 @@ This is the current matrix of available tests: | sahara | | X | | | trove | | X | | | horizon | X | | | -| manila | X | | | -| nagios | X | | | -| SSL | X | | | +| manila | X | | | +| nagios | X | | | +| SSL | X | | | To run these tests: diff --git a/bin/packstack b/bin/packstack deleted file mode 100755 index 102778f24..000000000 --- a/bin/packstack +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import os, sys - -try: - import packstack -except ImportError: - # packstack isn't installed, running from source checkout - sys.path.insert(0, os.path.join(os.path.split(sys.argv[0])[0], "..")) - import packstack - -os.environ["INSTALLER_PROJECT_DIR"] = os.path.abspath(os.path.split(packstack.__file__)[0]) - -from packstack.installer import run_setup -run_setup.main() diff --git a/bin/release.sh b/bin/release.sh deleted file mode 100755 index 8810f3f76..000000000 --- a/bin/release.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_PATH="${BASH_SOURCE[0]}" -SCRIPT_DIR=`dirname $SCRIPT_PATH` -cd $SCRIPT_DIR/.. - -if [ -n "$1" ] ; then - # tagged release - BRANCH=`git rev-parse --abbrev-ref HEAD` - git fetch gerrit - git tag -m $1 -s $1 gerrit/$BRANCH - git push gerrit tag $1 -else - # development release - VERSION=`python setup.py --version` - sed -i -e "s/RESERVE_STR = None/RESERVE_STR = '$VERSION'/g" packstack/version.py - python setup.py sdist - git checkout packstack/version.py -fi diff --git a/docs/conf.py b/docs/conf.py index 08e20631b..1bfb27a44 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,7 @@ import sys sys.path.append('..') -from packstack import version as packstackversion +from packstack.version import version_info # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -52,7 +52,7 @@ source_suffix = '.rst' # source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = 'packstack' # General information about the project. project = u'packstack' @@ -63,9 +63,9 @@ copyright = u'2012, Red Hat' # built documents. # # The short X.Y version. -version = packstackversion.version_string() +version = version_info.version_string() # The full version, including alpha/beta/rc tags. -release = version +release = version_info.release_string() # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/packstack/installer/basedefs.py b/packstack/installer/basedefs.py index 88ae6b561..aa6334fe5 100644 --- a/packstack/installer/basedefs.py +++ b/packstack/installer/basedefs.py @@ -34,6 +34,8 @@ PACKSTACK_SRC_DOC = pkg_resources.resource_filename( ) if os.path.exists(PACKSTACK_SRC_DOC): PACKSTACK_DOC = PACKSTACK_SRC_DOC +elif os.path.exists(os.path.join(sys.prefix, 'share/packstack/packstack.rst')): + PACKSTACK_DOC = os.path.join(sys.prefix, 'share/packstack/packstack.rst') else: PACKSTACK_DOC = '/usr/share/packstack/packstack.rst' @@ -44,8 +46,8 @@ except OSError: # directory is already created, check ownership stat = os.stat(PACKSTACK_VAR_DIR) if stat.st_uid == 0 and os.getuid() != stat.st_uid: - print ('%s is already created and owned by root. Please change ' - 'ownership and try again.' % PACKSTACK_VAR_DIR) + print('%s is already created and owned by root. Please change ' + 'ownership and try again.' % PACKSTACK_VAR_DIR) sys.exit(1) finally: uid, gid = get_current_user() @@ -54,8 +56,8 @@ finally: try: os.chown(PACKSTACK_VAR_DIR, uid, gid) except Exception as ex: - print ('Unable to change owner of %s. Please fix ownership ' - 'manually and try again.' % PACKSTACK_VAR_DIR) + print('Unable to change owner of %s. Please fix ownership ' + 'manually and try again.' % PACKSTACK_VAR_DIR) sys.exit(1) _tmpdirprefix = datetime.datetime.now().strftime('%Y%m%d-%H%M%S-') @@ -72,7 +74,7 @@ if os.path.exists(LATEST_LOG_DIR): try: os.unlink(LATEST_LOG_DIR) except OSError: - print ('Unable to delete symbol link for log dir %s.' % LATEST_LOG_DIR) + print('Unable to delete symbol link for log dir %s.' % LATEST_LOG_DIR) try: # Extract folder name at /var/tmp/packstack/ and do a relative @@ -80,14 +82,14 @@ try: os.symlink(os.path.basename(VAR_DIR), os.path.join(PACKSTACK_VAR_DIR, 'latest')) except OSError: - print ('Unable to create symbol link for log dir %s.' % LATEST_LOG_DIR) + print('Unable to create symbol link for log dir %s.' % LATEST_LOG_DIR) PUPPET_DEPENDENCIES = ['puppet', 'hiera', 'openssh-clients', 'tar', 'nc'] PUPPET_MODULES_DEPS = ['rubygem-json'] FILE_INSTALLER_LOG = "setup.log" -DIR_PROJECT_DIR = os.environ.get('INSTALLER_PROJECT_DIR', os.path.join(os.getcwd(), 'packstack')) +DIR_PROJECT_DIR = os.environ.get('INSTALLER_PROJECT_DIR', os.path.abspath(os.path.join(os.path.split(__file__)[0], '..'))) DIR_PLUGINS = os.path.join(DIR_PROJECT_DIR, "plugins") DIR_MODULES = os.path.join(DIR_PROJECT_DIR, "modules") diff --git a/packstack/installer/run_setup.py b/packstack/installer/run_setup.py index 965e836ee..139876df0 100644 --- a/packstack/installer/run_setup.py +++ b/packstack/installer/run_setup.py @@ -35,8 +35,8 @@ import output_messages from .exceptions import FlagValidationError from .exceptions import ParamValidationError -from packstack import version from packstack.modules.common import filtered_hosts +from packstack.version import version_info from setup_controller import Controller controller = Controller() @@ -799,7 +799,7 @@ def initCmdLineParser(): # Init parser and all general flags usage = "usage: %prog [options] [--help]" - parser = OptionParser(usage=usage, version="%prog {0} {1}".format(version.release_string(), version.version_string())) + parser = OptionParser(usage=usage, version="%prog {0}".format(version_info.version_string())) parser.add_option("--gen-answer-file", help="Generate a template of an answer file.") parser.add_option("--answer-file", help="Runs the configuration in non-interactive mode, extracting all information from the" "configuration file. using this option excludes all other options") diff --git a/packstack/version.py b/packstack/version.py index af4ae909b..f77344993 100644 --- a/packstack/version.py +++ b/packstack/version.py @@ -12,81 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import pkg_resources +import pbr.version -from .installer.utils import execute - - -VERSION = ['8', '0', '0'] -OS_RELEASE = 'Mitaka' -RESERVE_STR = None - - -def vr_from_git(): - """Returns VR string calculated from GIT repo.""" - proj_dir = os.path.dirname(os.path.dirname(__file__)) - rc, tag = execute( - 'git describe --exact-match', - workdir=proj_dir, - use_shell=True, - can_fail=False, - log=False - ) - if not rc: - # we are on tagged commit, so let's use the tag as VR string - return tag.strip() - - rc, description = execute( - 'git describe --always', - workdir=proj_dir, - use_shell=True, - log=False - ) - if '-' in description: - # last tag has been found - tag, snap_tag, git_hash = description.split('-') - else: - # no tag has been found - tag = '.'.join(VERSION) - rc, git_hash = execute( - 'git log -n1 --pretty=format:%h', - workdir=proj_dir, - use_shell=True, - log=False - ) - git_hash = 'g{0}'.format(git_hash) - rc, snap_tag = execute( - 'git log --oneline | wc -l', - workdir=proj_dir, - use_shell=True, - log=False - ) - - tag, snap_tag, git_hash = tag.strip(), snap_tag.strip(), git_hash.strip() - return '{tag}.dev{snap_tag}.{git_hash}'.format(**locals()) - - -def vr_from_setuptools(): - """Returns VR string fetched from setuptools.""" - requirement = pkg_resources.Requirement.parse('packstack') - provider = pkg_resources.get_provider(requirement) - return provider.version - - -def release_string(): - return OS_RELEASE - - -def version_string(): - try: - version = vr_from_git() - except Exception: - # Not a git repo, so get version from setuptools - try: - version = vr_from_setuptools() - except Exception: - # In case of problem with setuptools, return version - # saved by release.sh or VERSION if nothing was saved - version = RESERVE_STR if RESERVE_STR else '.'.join(VERSION) - return version +version_info = pbr.version.VersionInfo('packstack') diff --git a/requirements.txt b/requirements.txt index 6eb83c8ea..bb577d0ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +pbr>=1.6 # Apache-2.0 netaddr>=0.7.6 PyYAML>=3.10 docutils>=0.11 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..caa5c14a5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = packstack +summary = A utility to install OpenStack +description-file = README.md +author = RDO +author-email = rdo-list@redhat.com +home-page = http://www.rdoproject.org/ +classifier = + Environment :: OpenStack + 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.7 + +[files] +packages = + packstack + +data_files = + share/packstack = docs/packstack.rst + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + +[build_sphinx] +all_files = 1 +build-dir = docs/build +source-dir = docs + +[pbr] +warnerrors = True +autodoc_tree_index_modules = True + +[entry_points] +console_scripts = + packstack = packstack.installer.run_setup:main + diff --git a/setup.py b/setup.py index 46dfffb50..2e8329785 100644 --- a/setup.py +++ b/setup.py @@ -1,54 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# 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 -import os - -from setuptools import setup -from setuptools import find_packages - -from packstack import version - - -# Utility function to read the README file. -# Used for the long_description. It's nice, because now 1) we have a top level -# README file and 2) it's easier to type in the README file than to put a raw -# string in below ... -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -setup( - name="packstack", - version=version.version_string(), - author="Derek Higgins", - author_email="derekh@redhat.com", - description=("A utility to install OpenStack"), - license="ASL 2.0", - keywords="openstack", - url="https://github.com/openstack/packstack", - packages=find_packages('.') + ['docs'], - package_data={'docs': ['docs/packstack.rst']}, - include_package_data=True, - long_description=read('README.md'), - zip_safe=False, - install_requires=['netaddr>=0.7.6', 'pyOpenSSL<15.0.0', 'PyYAML>=3.10', - 'docutils>=0.11', 'cryptography!=1.3.0,>=1.0'], - classifiers=[ - "Development Status :: 3 - Alpha", - "Topic :: Utilities", - "License :: OSI Approved :: Apache Software License", - ], - scripts=["bin/packstack"] -) +setuptools.setup( + setup_requires=['pbr>=1.8'], + pbr=True) diff --git a/tox.ini b/tox.ini index 2b5c2598c..8de06f912 100644 --- a/tox.ini +++ b/tox.ini @@ -38,4 +38,4 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen # All other checks should be enabled in the future. ignore = E123,E125,H803,F403,F821,F811,F841,E501,H302,H303,H304,H306,H405,H404,H305,H307,H501,H201,H101 show-source = True -exclude=.venv,.git,.tox \ No newline at end of file +exclude=.venv,.git,.tox,.eggs