forked from eucalyptus/eucaconsole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
176 lines (158 loc) · 6.24 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
166
167
168
169
170
171
172
173
174
175
176
# Copyright 2013-2014 Eucalyptus Systems, Inc.
#
# Redistribution and use of this software in source and binary forms,
# with or without modification, are permitted provided that the following
# conditions are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import re
from distutils.command.build_py import build_py
from distutils.command.sdist import sdist
from setuptools import setup, find_packages
from eucaconsole import __version__
DATA_DIR='/usr/share/'
def get_data_files(path, regex):
data_files = []
for root, _, filenames in os.walk(path, followlinks=True):
files = []
for file in filenames:
if re.match(regex, file) is not None:
files.append(os.path.join(root, file))
data_files.append((os.path.join(DATA_DIR, root), files))
return data_files
def get_package_files(package_dir, regex):
package_files = []
if not package_dir.endswith('/'):
package_dir = package_dir + '/'
for root, _, filenames in os.walk(package_dir, followlinks=True):
files = []
for file in filenames:
package_path = os.path.join(root[len(package_dir):], file)
if re.match(regex, package_path) is not None:
files.append(package_path)
package_files.extend(files)
return package_files
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.rst')) as f:
README = f.read()
class build_py_with_git_version(build_py):
'''Like build_py, but also hardcoding the version in version.__version__
so it's consistent even outside of the source tree'''
def build_module(self, module, module_file, package):
build_py.build_module(self, module, module_file, package)
print module, module_file, package
if module == 'version' and '.' not in package:
version_line = "__version__ = '{0}'\n".format(__version__)
old_ver_name = self.get_module_outfile(self.build_lib, (package,),
module)
new_ver_name = old_ver_name + '.new'
with open(new_ver_name, 'w') as new_ver:
with open(old_ver_name) as old_ver:
for line in old_ver:
if line.startswith('__version__ ='):
new_ver.write(version_line)
else:
new_ver.write(line)
new_ver.flush()
os.rename(new_ver_name, old_ver_name)
class sdist_with_git_version(sdist):
'''Like sdist, but also hardcoding the version in version.__version__ so
it's consistent even outside of the source tree'''
def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
version_line = "__version__ = '{0}'\n".format(__version__)
old_ver_name = os.path.join(base_dir, 'eucaconsole/version.py')
new_ver_name = old_ver_name + '.new'
with open(new_ver_name, 'w') as new_ver:
with open(old_ver_name) as old_ver:
for line in old_ver:
if line.startswith('__version__ ='):
new_ver.write(version_line)
else:
new_ver.write(line)
new_ver.flush()
os.rename(new_ver_name, old_ver_name)
requires = [
'beaker >= 1.5.4',
'boto >= 2.27.0',
'chameleon >= 2.5.3',
'gevent >= 0.13.8', # Note: gevent 1.0 no longer requires libevent, it bundles libev instead
# 'greenlet >= 0.3.1',
'gunicorn >= 18.0',
'M2Crypto >= 0.20.2',
'markupsafe >= 0.9.2',
'pycrypto >= 2.0.1',
'Paste >= 1.7.4',
'pyramid >= 1.4',
'pyramid_beaker >= 0.8',
'pyramid_chameleon >= 0.1',
'pyramid_layout <= 0.8',
'python-dateutil >= 1.4.1', # Don't use 2.x series unless on Python 3
'simplejson >= 2.0.9',
'WTForms >= 1.0.2',
]
i18n_extras = [
'Babel',
'lingua == 1.6',
]
dev_extras = [
'pyramid_debugtoolbar',
'waitress',
]
message_extractors = {'eucaconsole': [
('**.py', 'lingua_python', None),
('**.pt', 'lingua_xml', None),
]}
setup(
name='eucaconsole',
version=__version__,
description='Eucalyptus Management Console',
long_description=README,
classifiers=[
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='Eucalyptus Systems',
author_email='[email protected]',
url='http://www.eucalyptus.com',
keywords='web pyramid pylons',
packages=find_packages(),
package_data={'eucaconsole': get_package_files('eucaconsole', r'^[static\|templates]\.*')},
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=[],
extras_require={
'i18n': i18n_extras,
'dev': dev_extras,
},
message_extractors=message_extractors,
data_files=get_data_files("locale", r'.*\.mo$'),
test_suite="tests",
entry_points="""\
[paste.app_factory]
main = eucaconsole.config:main
""",
cmdclass={'build_py': build_py_with_git_version,
'sdist': sdist_with_git_version}
)