diff --git a/ceilometer/openstack/common/setup.py b/ceilometer/openstack/common/setup.py new file mode 100644 index 000000000..17ca73d94 --- /dev/null +++ b/ceilometer/openstack/common/setup.py @@ -0,0 +1,83 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# 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. + +""" +Utilities with minimum-depends for use in setup.py +""" + +import datetime +import os +import re +import subprocess +import sys + +from setuptools.command import sdist + + +# Get requirements from the first file that exists +def get_reqs_from_files(requirements_files): + for requirements_file in requirements_files: + if os.path.exists(requirements_file): + return open(requirements_file, 'r').read().split('\n') + return [] + + +def parse_requirements(requirements_files=['requirements.txt', + 'tools/pip-requires']): + requirements = [] + for line in get_reqs_from_files(requirements_files): + # For the requirements list, we need to inject only the portion + # after egg= so that distutils knows the package it's looking for + # such as: + # -e git://github.com/openstack/nova/master#egg=nova + if re.match(r'\s*-e\s+', line): + requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', + line)) + # such as: + # http://github.com/openstack/nova/zipball/master#egg=nova + elif re.match(r'\s*https?:', line): + requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1', + line)) + # -f lines are for index locations, and don't get used here + elif re.match(r'\s*-f\s+', line): + pass + # argparse is part of the standard library starting with 2.7 + # adding it to the requirements list screws distro installs + elif line == 'argparse' and sys.version_info >= (2, 7): + pass + else: + requirements.append(line) + + return requirements + + +def parse_dependency_links(requirements_files=['requirements.txt', + 'tools/pip-requires']): + dependency_links = [] + # dependency_links inject alternate locations to find packages listed + # in requirements + for line in get_reqs_from_files(requirements_files): + # skip comments and blank lines + if re.match(r'(\s*#)|(\s*$)', line): + continue + # lines with -e or -f need the whole line, minus the flag + if re.match(r'\s*-[ef]\s+', line): + dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line)) + # lines that are only urls can go in unmolested + elif re.match(r'\s*https?:', line): + dependency_links.append(line) + return dependency_links diff --git a/setup.py b/setup.py index 3c1e89a75..2143e8682 100755 --- a/setup.py +++ b/setup.py @@ -21,6 +21,11 @@ import textwrap import setuptools +from ceilometer.openstack.common import setup + +requires = setup.parse_requirements() +depend_links = setup.parse_dependency_links() + setuptools.setup( name='ceilometer', version='0', @@ -37,6 +42,8 @@ setuptools.setup( 'bin/ceilometer-api', 'bin/ceilometer-collector'], py_modules=[], + install_requires=requires, + dependency_links=depend_links, entry_points=textwrap.dedent(""" [ceilometer.collector] instance = ceilometer.compute.notifications:Instance diff --git a/tools/pip-requires b/tools/pip-requires index cd7024cb8..6027dd620 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -1,5 +1,3 @@ -http://tarballs.openstack.org/nova/nova-master.tar.gz -http://tarballs.openstack.org/glance/glance-master.tar.gz webob kombu iso8601 @@ -8,6 +6,6 @@ netaddr argparse sqlalchemy eventlet -anyjson==0.3.1 +anyjson>=0.3.1 Flask==0.9 stevedore>=0.4 diff --git a/tools/pip-requires_essex b/tools/pip-requires_essex deleted file mode 100644 index 656aebbb7..000000000 --- a/tools/pip-requires_essex +++ /dev/null @@ -1,13 +0,0 @@ -https://github.com/openstack/openstack-common/zipball/master#egg=openstack.common -https://github.com/openstack/nova/zipball/2012.1.1#egg=nova -https://github.com/openstack/python-novaclient/zipball/2012.1#egg=novaclient -webob -kombu -iso8601 -lockfile -netaddr -argparse -sqlalchemy -anyjson==0.3.1 -Flask==0.9 -stevedore>=0.4 diff --git a/tools/test-requires b/tools/test-requires index 2f438120b..c0e0106f1 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -3,7 +3,6 @@ coverage pep8>=1.0 mock mox -glance>=2011.3.1 python-glanceclient # NOTE(dhellmann): Ming is necessary to provide the Mongo-in-memory # implementation of MongoDB. The original source for Ming is at @@ -13,4 +12,6 @@ python-glanceclient # github to make it easier to install, then ended up making some # changes to it so it would be compatible with PyMongo's API. https://github.com/dreamhost/Ming/zipball/master#egg=Ming +http://tarballs.openstack.org/nova/nova-master.tar.gz +http://tarballs.openstack.org/glance/glance-master.tar.gz setuptools-git>=0.4 diff --git a/tools/test-requires_essex b/tools/test-requires_essex deleted file mode 100644 index 8274f9a63..000000000 --- a/tools/test-requires_essex +++ /dev/null @@ -1 +0,0 @@ -carrot diff --git a/tox.ini b/tox.ini index 260218305..4e286b9a1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] -envlist = py26,py27,pep8,py26-essex,py27-essex +envlist = py26,py27,pep8 [testenv] -deps = -r{toxinidir}/tools/pip-requires - -r{toxinidir}/tools/test-requires +deps = -r{toxinidir}/tools/test-requires + -r{toxinidir}/tools/pip-requires setenv = VIRTUAL_ENV={envdir} NOSE_WITH_OPENSTACK=1 NOSE_OPENSTACK_COLOR=1 @@ -19,13 +19,3 @@ commands = {toxinidir}/run_tests.sh --no-path-adjustment --with-coverage --cover [testenv:pep8] deps = pep8==1.1 commands = pep8 --repeat --show-source ceilometer setup.py bin/ceilometer-agent-central bin/ceilometer-agent-compute bin/ceilometer-collector bin/ceilometer-api tests - -[testenv:py26-essex] -deps = -r{toxinidir}/tools/pip-requires_essex - -r{toxinidir}/tools/test-requires - -r{toxinidir}/tools/test-requires_essex - -[testenv:py27-essex] -deps = -r{toxinidir}/tools/pip-requires_essex - -r{toxinidir}/tools/test-requires - -r{toxinidir}/tools/test-requires_essex