-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.py
165 lines (141 loc) · 5.02 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
import os
import sys
from distutils.core import setup
from distutils.core import Command
from unittest import TextTestRunner, TestLoader
from glob import glob
from os.path import splitext, basename, join as pjoin
import libcloud.utils
libcloud.utils.SHOW_DEPRECATION_WARNING = False
HTML_VIEWSOURCE_BASE = 'https://svn.apache.org/viewvc/incubator/libcloud/trunk'
PROJECT_BASE_DIR = 'http://incubator.apache.org/libcloud/'
TEST_PATHS = [ 'test', 'test/compute', 'test/storage' ]
class TestCommand(Command):
user_options = []
def initialize_options(self):
THIS_DIR = os.path.abspath(os.path.split(__file__)[0])
sys.path.insert(0, THIS_DIR)
for test_path in TEST_PATHS:
sys.path.insert(0, pjoin(THIS_DIR, test_path))
self._dir = os.getcwd()
def finalize_options(self):
pass
def run(self):
status = self._run_tests()
sys.exit(status)
def _run_tests(self):
secrets = pjoin(self._dir, 'test', 'secrets.py')
if not os.path.isfile(secrets):
print "Missing %s" % (secrets)
print "Maybe you forgot to copy it from -dist:"
print " cp test/secrets.py-dist test/secrets.py"
sys.exit(1)
pre_python26 = (sys.version_info[0] == 2
and sys.version_info[1] < 6)
if pre_python26:
missing = []
# test for dependencies
try:
import simplejson
except ImportError:
missing.append("simplejson")
try:
import ssl
except ImportError:
missing.append("ssl")
if missing:
print "Missing dependencies: %s" % ", ".join(missing)
sys.exit(1)
testfiles = []
for test_path in TEST_PATHS:
for t in glob(pjoin(self._dir, test_path, 'test_*.py')):
testfiles.append('.'.join(
[test_path.replace('/', '.'), splitext(basename(t))[0]])
)
tests = TestLoader().loadTestsFromNames(testfiles)
t = TextTestRunner(verbosity = 2)
res = t.run(tests)
return not res.wasSuccessful()
class ApiDocsCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system(
'pydoctor'
' --add-package=libcloud'
' --project-name=libcloud'
' --make-html'
' --html-viewsource-base="%s"'
' --project-base-dir=`pwd`'
' --project-url="%s"'
% (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR)
)
class CoverageCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import coverage
cov = coverage.coverage(config_file='.coveragerc')
cov.start()
tc = TestCommand(self.distribution)
tc._run_tests()
cov.stop()
cov.save()
cov.html_report()
# pre-2.6 will need the ssl PyPI package
pre_python26 = (sys.version_info[0] == 2 and sys.version_info[1] < 6)
setup(
name='apache-libcloud',
version='0.4.3',
description='A unified interface into many cloud server providers',
author='Apache Software Foundation',
author_email='[email protected]',
requires=([], ['ssl', 'simplejson'],)[pre_python26],
packages=[
'libcloud',
'libcloud.common',
'libcloud.compute',
'libcloud.compute.drivers',
'libcloud.drivers',
],
package_dir={
'libcloud': 'libcloud',
'libcloud.drivers': 'libcloud/drivers'
},
license='Apache License (2.0)',
url='http://incubator.apache.org/libcloud/',
cmdclass={
'test': TestCommand,
'apidocs': ApiDocsCommand,
'coverage': CoverageCommand
},
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'
],
)