Allow python-fuelclient to be packaged properly

- Use pbr
 - Clean up extra dependencies
 - Trigger Nailgun's scripts in their own virtual
   environment

Blueprint: re-thinking-fuel-client
Change-Id: Icbf2df4c056cc9adf6a01e67d4e06a979cefa274
This commit is contained in:
Roman Prykhodchenko
2015-01-20 18:27:11 +01:00
parent cb8928ce34
commit 356f1df285
7 changed files with 82 additions and 63 deletions

21
fuelclient/hooks.py Normal file
View File

@@ -0,0 +1,21 @@
# Copyright 2015 Mirantis, Inc.
#
# 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.
def setup_hook(config):
import pbr
import pbr.packaging
# this monkey patch is to avoid appending git version to version
pbr.packaging._get_version_from_git = lambda pre_version: pre_version

View File

@@ -65,8 +65,6 @@ class UnitTestCase(TestCase):
class BaseTestCase(UnitTestCase):
nailgun_root = os.environ.get('NAILGUN_ROOT', '/tmp/fuel_web/nailgun')
manage_path = os.path.join(nailgun_root, 'manage.py')
def setUp(self):
self.reload_nailgun_server()
self.temp_directory = tempfile.mkdtemp()
@@ -75,12 +73,13 @@ class BaseTestCase(UnitTestCase):
shutil.rmtree(self.temp_directory)
@staticmethod
def run_command(*args):
def run_command(*args, **kwargs):
handle = subprocess.Popen(
[" ".join(args)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True
stdout=kwargs.pop('stdout', subprocess.PIPE),
stderr=kwargs.pop('stderr', subprocess.PIPE),
shell=kwargs.pop('shell', True),
**kwargs
)
log.debug("Running " + " ".join(args))
out, err = handle.communicate()
@@ -95,14 +94,16 @@ class BaseTestCase(UnitTestCase):
@classmethod
def reload_nailgun_server(cls):
for action in ("dropdb", "syncdb", "loaddefault"):
cls.run_command(cls.manage_path, action)
cmd = 'tox -evenv -- manage.py %s' % action
cls.run_command(cmd, cwd=cls.nailgun_root)
@classmethod
def load_data_to_nailgun_server(cls):
file_path = os.path.join(cls.nailgun_root,
'nailgun/fixtures/sample_environment.json')
cls.run_command(cls.manage_path, "loaddata {0}".format(file_path))
cmd = 'tox -evenv -- manage.py loaddata %s' % file_path
cls.run_command(cmd, cwd=cls.nailgun_root)
def run_cli_command(self, command_line, check_errors=False):
modified_env = os.environ.copy()

View File

@@ -1,28 +1,6 @@
Babel==1.3
Jinja2==2.7
Mako==0.9.1
MarkupSafe==0.18
Paste==1.7.5.1
argparse==1.2.1
pbr>=0.6,!=0.7,<1.0
python-keystoneclient>=0.7.1,<=0.7.2
PyYAML==3.10
requests>=1.2.3
SQLAlchemy>=0.9.4
Shotgun==0.1.0
alembic==0.6.2
amqplib==1.0.2
anyjson==0.3.3
argparse==1.2.1
decorator==3.4.0
fysom==1.0.11
iso8601==0.1.9
jsonschema==2.3.0
kombu==3.0.16
netaddr==0.7.10
oslo.config==1.2.1
psycopg2==2.5.1
pycrypto==2.6.1
simplejson==3.3.0
six>=1.5.2
web.py==0.37
wsgilog==0.3
wsgiref==0.1.2
python-keystoneclient>=0.7.1,<=0.7.2

34
setup.cfg Normal file
View File

@@ -0,0 +1,34 @@
[metadata]
name = python-fuelclient
version = 6.0.0
summary = Command line interface and Python API wrapper for Fuel.
author = Mirantis Inc.
author-email = product@mirantis.com
home-page = http://mirantis.com
description-file =
README.rst
classifier =
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
[files]
packages =
fuelclient
[entry_points]
console_scripts =
fuel = fuelclient.cli.parser:main
[global]
setup-hooks =
pbr.hooks.setup_hook
fuelclient.hooks.setup_hook
[wheel]
universal = 1

View File

@@ -12,23 +12,17 @@
# License for the specific language governing permissions and limitations
# under the License.
from setuptools import find_packages
from setuptools import setup
import setuptools
setup(
name='python-fuelclient',
version='6.0.0',
description='Command line interface for Nailgun',
long_description="""Command line interface for Nailgun""",
author='Mirantis Inc.',
author_email='product@mirantis.com',
url='http://mirantis.com',
install_requires=['PyYAML==3.10', "argparse==1.2.1"],
packages=find_packages(),
package_data = {'': ['*.yaml']},
entry_points={
'console_scripts': [
'fuel = fuelclient.cli.parser:main',
],
}
)
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
pbr=True)

View File

@@ -1,17 +1,7 @@
-r requirements.txt
hacking==0.7
mock==1.0
nose==1.1.2
nose2==0.4.1
nose-timer==0.2.0
sphinx==1.2
rst2pdf==0.93
sphinxcontrib-plantuml==0.3
sphinxcontrib-blockdiag==1.3.0
sphinxcontrib-actdiag==0.6.0
sphinxcontrib-seqdiag==0.6.0
sphinxcontrib-nwdiag==0.7.0
webtest==2.0.14
ply==3.4
pyprof2calltree==1.3.2
gprof2dot==2014.09.29

View File

@@ -7,7 +7,8 @@ envlist = py26,py27,pep8
usedevelop = True
install_command = pip install --allow-external -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
nosetests {posargs:fuelclient}