forked from vmware-archive/salt-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·156 lines (139 loc) · 4.96 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
#!/usr/bin/env python
'''
The setup script for salt
'''
import os
import urllib2
from distutils import log
from distutils.core import setup
from distutils.command.sdist import sdist as original_sdist
setup_kwargs = {}
USE_SETUPTOOLS = False
SALTCLOUD_SOURCE_DIR = os.path.abspath(os.path.dirname(__file__))
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
# The user can provide a different bootstrap-script version.
# ATTENTION: A tag for that version MUST exist
'BOOTSTRAP_SCRIPT_VERSION',
# If no bootstrap-script version was provided from the environment, let's
# provide the one we define.
'v1.5.4'
)
if 'USE_SETUPTOOLS' in os.environ:
try:
from setuptools import setup
from setuptools.command.sdist import sdist as original_sdist
USE_SETUPTOOLS = True
saltcloud_reqs = os.path.join(SALTCLOUD_SOURCE_DIR, 'requirements.txt')
requirements = ''
with open(saltcloud_reqs) as f:
requirements = f.read()
setup_kwargs['install_requires'] = requirements
except:
USE_SETUPTOOLS = False
if USE_SETUPTOOLS is False:
from distutils.core import setup
exec(
compile(
open('saltcloud/version.py').read(), 'saltcloud/version.py', 'exec'
)
)
class sdist(original_sdist):
user_options = original_sdist.user_options + [
('skip-bootstrap-download', None,
'Skip downloading the bootstrap-salt.sh script. This can also be '
'triggered by having `SKIP_BOOTSTRAP_DOWNLOAD=1` as an environment '
'variable.')
]
boolean_options = original_sdist.boolean_options + [
'skip-bootstrap-download'
]
def initialize_options(self):
original_sdist.initialize_options(self)
self.skip_bootstrap_download = False
def finalize_options(self):
original_sdist.finalize_options(self)
if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
skip_bootstrap_download = os.environ.get(
'SKIP_BOOTSTRAP_DOWNLOAD', '0'
)
self.skip_bootstrap_download = skip_bootstrap_download == '1'
def run(self):
if self.skip_bootstrap_download is False:
# Let's update the bootstrap-script to the version defined to be
# distributed. See BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION above.
url = (
'https://github.com/saltstack/salt-bootstrap/raw/{0}'
'/bootstrap-salt.sh'.format(
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION
)
)
req = urllib2.urlopen(url)
deploy_path = os.path.join(
SALTCLOUD_SOURCE_DIR,
'saltcloud',
'deploy',
'bootstrap-salt.sh'
)
if req.getcode() == 200:
try:
log.info(
'Updating bootstrap-salt.sh.'
'\n\tSource: {0}'
'\n\tDestination: {1}'.format(
url,
deploy_path
)
)
with open(deploy_path, 'w') as fp_:
fp_.write(req.read())
except (OSError, IOError), err:
log.error(
'Failed to write the updated script: {0}'.format(err)
)
else:
log.error(
'Failed to update the bootstrap-salt.sh script. HTTP '
'Error code: {0}'.format(
req.getcode()
)
)
# Let's the rest of the build command
original_sdist.run(self)
NAME = 'salt-cloud'
VER = __version__
DESC = ('Generic cloud provisioning system with build in functions ')
setup(name=NAME,
version=VER,
description=DESC,
author='Thomas S Hatch',
author_email='[email protected]',
url='http://saltstack.org',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Topic :: System :: Distributed Computing',
],
packages=['saltcloud',
'saltcloud/utils',
'saltcloud/clouds',
],
package_data={
'saltcloud': ['deploy/*.sh'],
},
data_files=[('share/man/man1', ['doc/man/salt-cloud.1']),
('share/man/man7', ['doc/man/salt-cloud.7'])
],
scripts=['scripts/salt-cloud'],
cmdclass={
'sdist': sdist
},
**setup_kwargs
)