Skip to content
Newer
Older
100644 249 lines (206 sloc) 7.52 KB
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 import os
16 import sys
ade53bc @Kami Also run doc tests.
Kami authored Mar 16, 2011
17 import doctest
18
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
19 from distutils.core import setup
20 from distutils.core import Command
21 from unittest import TextTestRunner, TestLoader
22 from glob import glob
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
23 from subprocess import call
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
24 from os.path import splitext, basename, join as pjoin
25
23bbc25 @Kami Re-organize libcloud.utils modules and create a new libcloud.utils pa…
Kami authored Dec 4, 2011
26 import libcloud.utils.misc
27 libcloud.utils.misc.SHOW_DEPRECATION_WARNING = False
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
28
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
29
c0a7923 @Kami Remove incubator from the path.
Kami authored Jun 14, 2011
30 HTML_VIEWSOURCE_BASE = 'https://svn.apache.org/viewvc/libcloud/trunk'
1d46a20 @Kami Remove incubator from the link.
Kami authored Jun 17, 2011
31 PROJECT_BASE_DIR = 'http://libcloud.apache.org'
6761b76 @Kami Add Ninefold.com compute and load-balancer driver.
Kami authored Jun 30, 2011
32 TEST_PATHS = ['test', 'test/common', 'test/compute', 'test/storage',
6b47954 @Kami Running setup.py test should now also run DNS tests.
Kami authored Sep 23, 2011
33 'test/loadbalancer', 'test/dns']
6693e7b @Kami Update CHANGES and setup.py.
Kami authored Dec 3, 2011
34 DOC_TEST_MODULES = ['libcloud.compute.drivers.dummy',
95f0733 @Kami Fix dummy DNS driver and also run dummy driver doc tests when running…
Kami authored Sep 23, 2011
35 'libcloud.storage.drivers.dummy',
6693e7b @Kami Update CHANGES and setup.py.
Kami authored Dec 3, 2011
36 'libcloud.dns.drivers.dummy']
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
37
6693e7b @Kami Update CHANGES and setup.py.
Kami authored Dec 3, 2011
38 SUPPORTED_VERSIONS = ['2.5', '2.6', '2.7', 'PyPy', '3.x']
39
40 if sys.version_info <= (2, 4):
41 version = '.'.join([str(x) for x in sys.version_info[:3]])
42 print('Version ' + version + ' is not supported. Supported versions are ' +
43 ', '.join(SUPPORTED_VERSIONS))
44 sys.exit(1)
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
45
3785d73 @Kami pep8.
Kami authored Dec 3, 2011
46
1bd6a4b @Kami Read the version number from the libcloud/__init__.py file
Kami authored May 21, 2011
47 def read_version_string():
48 version = None
49 sys.path.insert(0, pjoin(os.getcwd()))
50 from libcloud import __version__
51 version = __version__
1693b95 @Kami Forgot to pop it.
Kami authored May 21, 2011
52 sys.path.pop(0)
1bd6a4b @Kami Read the version number from the libcloud/__init__.py file
Kami authored May 21, 2011
53 return version
54
3785d73 @Kami pep8.
Kami authored Dec 3, 2011
55
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
56 class TestCommand(Command):
45a9c4d @novel Provide description for our custom distutils commands.
novel authored Jun 24, 2011
57 description = "run test suite"
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
58 user_options = []
59
60 def initialize_options(self):
61 THIS_DIR = os.path.abspath(os.path.split(__file__)[0])
62 sys.path.insert(0, THIS_DIR)
63 for test_path in TEST_PATHS:
24f1142 @Kami Apply Tavis Rodd's patch (style fixes, cloudfiles test fixes, cloudfi…
Kami authored Mar 15, 2011
64 sys.path.insert(0, pjoin(THIS_DIR, test_path))
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
65 self._dir = os.getcwd()
66
67 def finalize_options(self):
68 pass
69
70 def run(self):
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
71 try:
72 import mock
73 mock
74 except ImportError:
9459699 @Kami Start working on Python 3 compatibility.
Kami authored Dec 3, 2011
75 print('Missing "mock" library. mock is library is needed '
76 'to run the tests. You can install it using pip: '
77 'pip install mock')
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
78 sys.exit(1)
79
4c36877 @Kami Add coverage command.
Kami authored Mar 14, 2011
80 status = self._run_tests()
81 sys.exit(status)
82
83 def _run_tests(self):
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
84 secrets = pjoin(self._dir, 'test', 'secrets.py')
85 if not os.path.isfile(secrets):
21d53eb @Kami Update setup.py
Kami authored Dec 3, 2011
86 print("Missing " + secrets)
9459699 @Kami Start working on Python 3 compatibility.
Kami authored Dec 3, 2011
87 print("Maybe you forgot to copy it from -dist:")
88 print(" cp test/secrets.py-dist test/secrets.py")
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
89 sys.exit(1)
90
91 pre_python26 = (sys.version_info[0] == 2
92 and sys.version_info[1] < 6)
93 if pre_python26:
94 missing = []
95 # test for dependencies
96 try:
97 import simplejson
24f1142 @Kami Apply Tavis Rodd's patch (style fixes, cloudfiles test fixes, cloudfi…
Kami authored Mar 15, 2011
98 simplejson # silence pyflakes
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
99 except ImportError:
100 missing.append("simplejson")
101
102 try:
103 import ssl
24f1142 @Kami Apply Tavis Rodd's patch (style fixes, cloudfiles test fixes, cloudfi…
Kami authored Mar 15, 2011
104 ssl # silence pyflakes
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
105 except ImportError:
106 missing.append("ssl")
107
108 if missing:
21d53eb @Kami Update setup.py
Kami authored Dec 3, 2011
109 print("Missing dependencies: " + ", ".join(missing))
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
110 sys.exit(1)
111
112 testfiles = []
113 for test_path in TEST_PATHS:
24f1142 @Kami Apply Tavis Rodd's patch (style fixes, cloudfiles test fixes, cloudfi…
Kami authored Mar 15, 2011
114 for t in glob(pjoin(self._dir, test_path, 'test_*.py')):
115 testfiles.append('.'.join(
116 [test_path.replace('/', '.'), splitext(basename(t))[0]]))
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
117
118 tests = TestLoader().loadTestsFromNames(testfiles)
ade53bc @Kami Also run doc tests.
Kami authored Mar 16, 2011
119
120 for test_module in DOC_TEST_MODULES:
121 tests.addTests(doctest.DocTestSuite(test_module))
122
3785d73 @Kami pep8.
Kami authored Dec 3, 2011
123 t = TextTestRunner(verbosity=2)
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
124 res = t.run(tests)
4c36877 @Kami Add coverage command.
Kami authored Mar 14, 2011
125 return not res.wasSuccessful()
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
126
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
127
128 class Pep8Command(Command):
129 description = "run pep8 script"
130 user_options = []
131
132 def initialize_options(self):
133 pass
134
135 def finalize_options(self):
136 pass
137
138 def run(self):
139 try:
140 import pep8
141 pep8
142 except ImportError:
9459699 @Kami Start working on Python 3 compatibility.
Kami authored Dec 3, 2011
143 print ('Missing "pep8" library. You can install it using pip: '
144 'pip install pep8')
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
145 sys.exit(1)
146
147 cwd = os.getcwd()
6a873a5 @Kami Don't specify full path to pep8 binary.
Kami authored Jun 28, 2011
148 retcode = call(('pep8 %s/libcloud/ %s/test/' %
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
149 (cwd, cwd)).split(' '))
150 sys.exit(retcode)
151
152
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
153 class ApiDocsCommand(Command):
45a9c4d @novel Provide description for our custom distutils commands.
novel authored Jun 24, 2011
154 description = "generate API documentation"
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
155 user_options = []
156
157 def initialize_options(self):
158 pass
159
160 def finalize_options(self):
161 pass
162
163 def run(self):
164 os.system(
165 'pydoctor'
166 ' --add-package=libcloud'
167 ' --project-name=libcloud'
168 ' --make-html'
169 ' --html-viewsource-base="%s"'
170 ' --project-base-dir=`pwd`'
171 ' --project-url="%s"'
3cda3be Fixed a few PEP8 compliance issues, and removed unused variables.
Hutson Betts authored Dec 11, 2011
172 % (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR))
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
173
3785d73 @Kami pep8.
Kami authored Dec 3, 2011
174
4c36877 @Kami Add coverage command.
Kami authored Mar 14, 2011
175 class CoverageCommand(Command):
45a9c4d @novel Provide description for our custom distutils commands.
novel authored Jun 24, 2011
176 description = "run test suite and generate coverage report"
4c36877 @Kami Add coverage command.
Kami authored Mar 14, 2011
177 user_options = []
178
179 def initialize_options(self):
180 pass
181
182 def finalize_options(self):
183 pass
184
185 def run(self):
186 import coverage
187 cov = coverage.coverage(config_file='.coveragerc')
188 cov.start()
189
190 tc = TestCommand(self.distribution)
191 tc._run_tests()
192
193 cov.stop()
194 cov.save()
195 cov.html_report()
196
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
197 # pre-2.6 will need the ssl PyPI package
198 pre_python26 = (sys.version_info[0] == 2 and sys.version_info[1] < 6)
199
200 setup(
201 name='apache-libcloud',
1bd6a4b @Kami Read the version number from the libcloud/__init__.py file
Kami authored May 21, 2011
202 version=read_version_string(),
a0ccbdc @Kami Update description in setup.py, add script for migrating from the old…
Kami authored Dec 4, 2011
203 description='A standard Python library that abstracts away differences' +
204 'among multiple cloud provider APIs',
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
205 author='Apache Software Foundation',
0f4fb1d @Kami Update author email and website url.
Kami authored May 25, 2011
206 author_email='dev@libcloud.apache.org',
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
207 requires=([], ['ssl', 'simplejson'],)[pre_python26],
208 packages=[
209 'libcloud',
23bbc25 @Kami Re-organize libcloud.utils modules and create a new libcloud.utils pa…
Kami authored Dec 4, 2011
210 'libcloud.utils',
e524a8c @novel Add missing packages to setup.py after refactoring.
novel authored Mar 9, 2011
211 'libcloud.common',
212 'libcloud.compute',
213 'libcloud.compute.drivers',
d5f4a62 @Kami Update setup.py, include storage packages.
Kami authored May 21, 2011
214 'libcloud.storage',
215 'libcloud.storage.drivers',
f85a6b5 @pquerna Rename libcloud.resources.lb to libcloud.loadbalancer'
pquerna authored May 14, 2011
216 'libcloud.loadbalancer',
217 'libcloud.loadbalancer.drivers',
6d724b3 @Kami Add dns module to setup.py.
Kami authored Oct 15, 2011
218 'libcloud.dns',
3cda3be Fixed a few PEP8 compliance issues, and removed unused variables.
Hutson Betts authored Dec 11, 2011
219 'libcloud.dns.drivers'],
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
220 package_dir={
221 'libcloud': 'libcloud',
222 },
c60b3bf @novel Include pricing data to package_data.
novel authored Mar 15, 2011
223 package_data={
06864a8 @Kami Update setup.py and MANIFEST.in
Kami authored May 21, 2011
224 'libcloud': ['data/*.json']
c60b3bf @novel Include pricing data to package_data.
novel authored Mar 15, 2011
225 },
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
226 license='Apache License (2.0)',
0f4fb1d @Kami Update author email and website url.
Kami authored May 25, 2011
227 url='http://libcloud.apache.org/',
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
228 cmdclass={
229 'test': TestCommand,
616d5b2 @Kami 1. Print an error if mock library cannot be found
Kami authored Jun 27, 2011
230 'pep8': Pep8Command,
4c36877 @Kami Add coverage command.
Kami authored Mar 14, 2011
231 'apidocs': ApiDocsCommand,
232 'coverage': CoverageCommand
80ccbfe @Kami Merge storage_api branch.
Kami authored Mar 7, 2011
233 },
234 classifiers=[
235 'Development Status :: 4 - Beta',
236 'Environment :: Console',
237 'Intended Audience :: System Administrators',
238 'License :: OSI Approved :: Apache Software License',
239 'Operating System :: OS Independent',
240 'Programming Language :: Python',
babd81a @Kami Bump version, add Python version classifiers to setup.py.
Kami authored Dec 4, 2011
241 'Topic :: Software Development :: Libraries :: Python Modules',
242 'Programming Language :: Python :: 2.5',
243 'Programming Language :: Python :: 2.6',
244 'Programming Language :: Python :: 2.7',
245 'Programming Language :: Python :: 3',
246 'Programming Language :: Python :: 3.0',
247 'Programming Language :: Python :: 3.1',
3cda3be Fixed a few PEP8 compliance issues, and removed unused variables.
Hutson Betts authored Dec 11, 2011
248 'Programming Language :: Python :: 3.2'])
Something went wrong with that request. Please try again.