Fix lp bug 897882
This moves the tree to having a standard setup.py. For those who want to build individual packages you'll need to use the setup_<package>.py files. This allows us to support the traditional setup.py commands (i.e. sdist, etc) that the openstack CI scripts will be using. Change-Id: I7fe286d9973f43ae118a715276b0c089230f4f7e
This commit is contained in:
parent
5b23b5ef6b
commit
f3a9665e43
|
@ -1,3 +1,4 @@
|
||||||
|
include bin/*
|
||||||
include etc/*
|
include etc/*
|
||||||
include etc/init.d/*
|
include etc/init.d/*
|
||||||
include etc/quantum/plugins/openvswitch/*
|
include etc/quantum/plugins/openvswitch/*
|
||||||
|
|
238
setup.py
238
setup.py
|
@ -1,169 +1,85 @@
|
||||||
from copy import deepcopy
|
try:
|
||||||
from optparse import OptionParser
|
from setuptools import setup, find_packages
|
||||||
from os import path
|
except ImportError:
|
||||||
import re
|
from ez_setup import use_setuptools
|
||||||
|
use_setuptools()
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import version
|
||||||
|
|
||||||
from tools import install_venv
|
Name = 'quantum'
|
||||||
|
Url = "https://launchpad.net/quantum"
|
||||||
|
Version = version.get_git_version()
|
||||||
|
License = 'Apache License 2.0'
|
||||||
|
Author = 'Netstack'
|
||||||
|
AuthorEmail = 'netstack@lists.launchpad.net'
|
||||||
|
Maintainer = ''
|
||||||
|
Summary = 'Quantum (virtual network service)'
|
||||||
|
ShortDescription = Summary
|
||||||
|
Description = Summary
|
||||||
|
|
||||||
ROOT = path.abspath(path.dirname(__file__))
|
requires = [
|
||||||
CONFIG_PATH = path.abspath('/etc/quantum')
|
'eventlet>=0.9.12',
|
||||||
BASE_PACKAGES = ['common', 'server', 'client']
|
'Routes>=1.12.3',
|
||||||
PLUGINS = ['sample_plugin', 'openvswitch_plugin', 'cisco_plugin']
|
'nose',
|
||||||
|
'Paste',
|
||||||
|
'PasteDeploy',
|
||||||
|
'pep8>=0.6.1',
|
||||||
|
'python-gflags',
|
||||||
|
'simplejson',
|
||||||
|
'sqlalchemy',
|
||||||
|
'webob',
|
||||||
|
'webtest'
|
||||||
|
]
|
||||||
|
|
||||||
RELATIVE = False
|
EagerResources = [
|
||||||
|
'quantum',
|
||||||
|
]
|
||||||
|
|
||||||
|
ProjectScripts = [
|
||||||
|
]
|
||||||
|
|
||||||
def clean_path(dirty):
|
config_path = 'etc/quantum/'
|
||||||
"""Makes sure path delimiters are OS compliant"""
|
init_path = 'etc/init.d'
|
||||||
return path.join(*dirty.split('/'))
|
ovs_plugin_config_path = 'etc/quantum/plugins/openvswitch'
|
||||||
|
cisco_plugin_config_path = 'etc/quantum/plugins/cisco'
|
||||||
|
|
||||||
|
print "config_path: %s" % config_path
|
||||||
|
DataFiles = [
|
||||||
|
(config_path,
|
||||||
|
['etc/quantum.conf', 'etc/quantum.conf.test', 'etc/plugins.ini']),
|
||||||
|
(init_path, ['etc/init.d/quantum-server']),
|
||||||
|
(ovs_plugin_config_path,
|
||||||
|
['etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini']),
|
||||||
|
(cisco_plugin_config_path,
|
||||||
|
['etc/quantum/plugins/cisco/credentials.ini',
|
||||||
|
'etc/quantum/plugins/cisco/l2network_plugin.ini',
|
||||||
|
'etc/quantum/plugins/cisco/nexus.ini',
|
||||||
|
'etc/quantum/plugins/cisco/ucs.ini',
|
||||||
|
'etc/quantum/plugins/cisco/cisco_plugins.ini',
|
||||||
|
'etc/quantum/plugins/cisco/db_conn.ini']),
|
||||||
|
]
|
||||||
|
|
||||||
def script_dir():
|
setup(
|
||||||
global RELATIVE
|
name=Name,
|
||||||
script_dir = '/usr/sbin/'
|
version=Version,
|
||||||
if RELATIVE:
|
url=Url,
|
||||||
script_dir = 'usr/sbin/'
|
author=Author,
|
||||||
return script_dir
|
author_email=AuthorEmail,
|
||||||
|
description=ShortDescription,
|
||||||
|
long_description=Description,
|
||||||
def etc_dir():
|
license=License,
|
||||||
global RELATIVE
|
scripts=ProjectScripts,
|
||||||
etc_dir = '/etc/'
|
install_requires=requires,
|
||||||
if RELATIVE:
|
include_package_data=False,
|
||||||
etc_dir = 'etc/'
|
packages=find_packages('.'),
|
||||||
return etc_dir
|
data_files=DataFiles,
|
||||||
|
eager_resources=EagerResources,
|
||||||
|
entry_points={
|
||||||
def create_parser():
|
'console_scripts': [
|
||||||
"""Setup the option parser"""
|
'quantum-server = quantum.server:main',
|
||||||
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
'quantum = quantum.client.cli:main',
|
||||||
parser = OptionParser(usage=usagestr)
|
]
|
||||||
parser.add_option("-V", "--virtualenv", "--venv", dest="venv",
|
},
|
||||||
action="store_true", default=False, help="Install to a virtual-env")
|
)
|
||||||
parser.add_option("-U", "--user", dest="user", action="store_true",
|
|
||||||
default=False, help="Install to users's home")
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
if args.__len__() is 0:
|
|
||||||
print usagestr
|
|
||||||
print "Commands:\ninstall\nuninstall\nbuild\nclean"
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
cmd = args[0]
|
|
||||||
args = args[1:]
|
|
||||||
return (options, cmd, args)
|
|
||||||
|
|
||||||
|
|
||||||
def install_packages(options, args=None):
|
|
||||||
"""Builds and installs packages"""
|
|
||||||
# Start building a command list
|
|
||||||
cmd = ['python']
|
|
||||||
|
|
||||||
# If no options, just a regular install. If venv, create, prepare and
|
|
||||||
# install in venv. If --user install in user's local dir. Usually
|
|
||||||
# ~/.local/
|
|
||||||
if options.venv:
|
|
||||||
if install_venv.VENV_EXISTS:
|
|
||||||
print "Virtual-env exists"
|
|
||||||
else:
|
|
||||||
install_venv.create_virtualenv(install_pip=False)
|
|
||||||
install_venv.install_dependencies()
|
|
||||||
cmd.insert(0, "tools/with_venv.sh")
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
# TODO(Tyler) allow users to pass in packages in cli
|
|
||||||
for package in BASE_PACKAGES + PLUGINS:
|
|
||||||
print "Installing %s" % package
|
|
||||||
# Each package needs its own command list, and it needs the path
|
|
||||||
# in the correct place (after "pip install")
|
|
||||||
pcmd = deepcopy(cmd)
|
|
||||||
pcmd.extend(["setup_%s.py" % package, "install"])
|
|
||||||
|
|
||||||
if options.venv:
|
|
||||||
pcmd.append("--root=%s" % install_venv.VENV)
|
|
||||||
|
|
||||||
if options.user:
|
|
||||||
pcmd.append('--user')
|
|
||||||
|
|
||||||
if package is 'client':
|
|
||||||
pcmd.append("--install-scripts=%s" % script_dir())
|
|
||||||
|
|
||||||
if package is 'server':
|
|
||||||
pcmd.append("--install-scripts=%s" % script_dir())
|
|
||||||
pcmd.append("--install-data=%s" % etc_dir())
|
|
||||||
print pcmd
|
|
||||||
install_venv.run_command(pcmd)
|
|
||||||
print "done."
|
|
||||||
|
|
||||||
|
|
||||||
def uninstall_packages(options, args=None):
|
|
||||||
"""Removes packages"""
|
|
||||||
cmd = ['pip', 'uninstall', '-y']
|
|
||||||
|
|
||||||
for package in ['quantum-' + x.split('/')[-1] \
|
|
||||||
for x in BASE_PACKAGES + PLUGINS]:
|
|
||||||
print "Uninstalling %s" % package
|
|
||||||
# Each package needs its own command list, and it needs the path
|
|
||||||
# in the correct place (after "pip uninstall"
|
|
||||||
pcmd = deepcopy(cmd)
|
|
||||||
pcmd.insert(2, package)
|
|
||||||
print pcmd
|
|
||||||
install_venv.run_command(pcmd)
|
|
||||||
print "done."
|
|
||||||
|
|
||||||
|
|
||||||
def build_packages(options, args=None):
|
|
||||||
"""Build RPM and/or deb packages"""
|
|
||||||
if not args:
|
|
||||||
print "To build packages you must specifiy either 'rpm', " \
|
|
||||||
"'deb', or 'all'"
|
|
||||||
exit(0)
|
|
||||||
if args[0] not in ['rpm', 'deb', 'all']:
|
|
||||||
raise Exception("Packge type must be rpm, deb, or all")
|
|
||||||
|
|
||||||
if 'rpm' in args or 'all' in args:
|
|
||||||
# Since we need to cd to build rpms, we call this sh script
|
|
||||||
cmd = ['tools/build_rpms.sh']
|
|
||||||
for package in BASE_PACKAGES + PLUGINS:
|
|
||||||
print "Building %s rpm" % package
|
|
||||||
pcmd = deepcopy(cmd)
|
|
||||||
pcmd.append(package)
|
|
||||||
install_venv.run_command(pcmd)
|
|
||||||
print "done."
|
|
||||||
|
|
||||||
if 'deb' in args or 'all' in args:
|
|
||||||
cmd = ['tools/build_debs.sh']
|
|
||||||
for p in BASE_PACKAGES + PLUGINS:
|
|
||||||
print "Building %s deb" % p
|
|
||||||
pcmd = deepcopy(cmd)
|
|
||||||
pcmd.append(p)
|
|
||||||
install_venv.run_command(pcmd)
|
|
||||||
print "done."
|
|
||||||
|
|
||||||
|
|
||||||
def clean_packages(options, args):
|
|
||||||
"""Cleans build packages"""
|
|
||||||
cmd = ["tools/clean.sh"]
|
|
||||||
install_venv.run_command(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Main Build script for Quantum"""
|
|
||||||
global RELATIVE
|
|
||||||
options, cmd, args = create_parser()
|
|
||||||
|
|
||||||
if options.user:
|
|
||||||
RELATIVE = True
|
|
||||||
|
|
||||||
print "Checking for virtual-env and easy_install"
|
|
||||||
install_venv.check_dependencies()
|
|
||||||
|
|
||||||
# Execute command
|
|
||||||
try:
|
|
||||||
globals()["%s_packages" % cmd](options, args)
|
|
||||||
except KeyError as exc:
|
|
||||||
print "Command %s' not found" % exc.__str__().split('_')[0]
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
python setup_$@.py bdist_rpm
|
|
|
@ -2,6 +2,7 @@ coverage
|
||||||
distribute>=0.6.24
|
distribute>=0.6.24
|
||||||
eventlet>=0.9.12
|
eventlet>=0.9.12
|
||||||
Routes>=1.12.3
|
Routes>=1.12.3
|
||||||
|
lxml==2.3
|
||||||
nose
|
nose
|
||||||
nosexcover
|
nosexcover
|
||||||
Paste
|
Paste
|
||||||
|
|
Loading…
Reference in New Issue