Make OpenStack requirements optional 79/6879/9
authorThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 14 Oct 2017 15:56:22 +0000 (11:56 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 30 Apr 2018 14:06:28 +0000 (10:06 -0400)
Users can now `pip install lftools[openstack]` as an optional
dependency so that we don't have to download the entire openstack
shade depchain.

Change-Id: Icf0065eeb1bf97f92560434edec3576397223af7
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
MANIFEST.in
docs/commands/openstack.rst
lftools/cli/__init__.py
lftools/openstack/no_cmd.py [new file with mode: 0644]
requirements-openstack.txt [new file with mode: 0644]
requirements.txt
setup.py
tox.ini

index 1a766a3..3456517 100644 (file)
@@ -2,4 +2,5 @@ include etc/logging.ini
 include README.md
 include requirements.txt
 include requirements-docs.txt
+include requirements-openstack.txt
 
index 566142e..eb33937 100644 (file)
@@ -2,6 +2,8 @@
 OpenStack
 *********
 
+Requires a `pip install lftools[openstack]` to activate this command.
+
 .. program-output:: lftools openstack --help
 
 Commands
index 022c5fc..ff844ff 100644 (file)
@@ -11,7 +11,6 @@
 
 __author__ = 'Thanh Ha'
 
-
 import click
 
 from lftools.cli.deploy import deploy
@@ -20,7 +19,6 @@ from lftools.cli.license import license
 from lftools.cli.nexus import nexus
 from lftools.cli.sign import sign
 from lftools.cli.version import version
-from lftools.openstack.cmd import openstack
 
 
 @click.group()
@@ -35,10 +33,16 @@ cli.add_command(deploy)
 cli.add_command(jenkins_cli, name='jenkins')
 cli.add_command(license)
 cli.add_command(nexus)
-cli.add_command(openstack)
 cli.add_command(sign)
 cli.add_command(version)
 
+try:
+    from lftools.openstack.cmd import openstack
+    cli.add_command(openstack)
+except ImportError:
+    from lftools.openstack.no_cmd import openstack
+    cli.add_command(openstack)
+
 
 def main():
     """Entry point for lftools CLI."""
diff --git a/lftools/openstack/no_cmd.py b/lftools/openstack/no_cmd.py
new file mode 100644 (file)
index 0000000..ad1a032
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- code: utf-8 -*-
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+"""CLI configuration for openstack command."""
+
+__author__ = 'Thanh Ha'
+
+
+import click
+
+
+@click.group()
+@click.pass_context
+def openstack(ctx, os_cloud):
+    """(lftools[openstack]) Provides an OpenStack interface.
+
+    To activate this interface run `pip install lftools[openstack]`.
+    """
+    pass
diff --git a/requirements-openstack.txt b/requirements-openstack.txt
new file mode 100644 (file)
index 0000000..5bb7784
--- /dev/null
@@ -0,0 +1 @@
+shade~=1.27.1
index ee16121..bfe5f33 100644 (file)
@@ -2,10 +2,7 @@ click
 pyyaml
 requests~=2.18.0
 setuptools>=36.5.0
-shade
 python-jenkins~=1.0.0
 
 # workarounds to prevent upstream from breaking us
-babel<2.4.0
 netifaces==0.10.5
-pbr<2.1.0
index c9081c5..933d740 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,9 @@ from lftools import __version__
 with open('requirements.txt') as f:
     install_reqs = f.read().splitlines()
 
+with open('requirements-openstack.txt') as f:
+    openstack_reqs = f.read().splitlines()
+
 setup(
     name='lftools',
     version=__version__,
@@ -36,6 +39,9 @@ setup(
         'Programming Language :: Python :: 3.5',
     ],
     install_requires=install_reqs,
+    extras_require={
+        'openstack': openstack_reqs,
+    },
     packages=find_packages(exclude=[
         '*.tests',
         '*.tests.*',
diff --git a/tox.ini b/tox.ini
index cca03c3..f2f6c6d 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,13 @@ envlist =
     py3
 
 [testenv]
-deps = -r{toxinidir}/requirements-test.txt
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/requirements-openstack.txt
+    -r{toxinidir}/requirements-test.txt
+    pytest
+    pytest-click
+    pytest-datafiles
 commands = pytest
 
 [testenv:coala]