-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·333 lines (298 loc) · 12.6 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
from __future__ import print_function
import sys, os, os.path, re, shutil, string
from distutils.core import setup, Command
from distutils.command.build import build
from distutils.command.install import install
from distutils.spawn import spawn
from glob import glob
systems = \
{
'dbs-client':
{
'srcdir': 'Client/src/python',
'bin': ['Client/cmdline/dbs.py'],
'pythonmods': ['dbs.__init__'],
'pythonpkg': ['dbs.apis', 'dbs.exceptions'],
'examples': ['Client/utils/*.py', 'Client/utils/DataOpsScripts/*.py']
},
'dbs-web':
{
'srcdir': 'Server/Python/src',
'pythonmods': ['dbs.__init__',
'dbs.web.DBSReaderModel',
'dbs.web.DBSWriterModel',
'dbs.web.DBSMigrateModel'],
'pythonpkg': [],
'dependencies' : ['dbs-business', 'dbs-dao', 'dbs-utils'],
'statics': ['Server/templates/*.tmpl']
},
'pycurl-client':
{
'srcdir': 'PycurlClient/src/python',
'pythonmods': ['RestClient.__init__',
'RestClient.RestApi'],
'pythonpkg': ['RestClient.AuthHandling',
'RestClient.ErrorHandling',
'RestClient.ProxyPlugins',
'RestClient.RequestHandling']
},
'dbs-migration':
{
'srcdir': 'Server/Python/src',
'pythonmods': ['dbs.__init__',
'dbs.components.__init__'],
'pythonpkg': ['dbs.components.migration'],
'dependencies' : ['dbs-business', 'dbs-dao', 'dbs-utils']
},
'dbs-business':
{
'srcdir': 'Server/Python/src',
'pythonmods': [],
'pythonpkg': ['dbs.business'],
'dependencies' : ['dbs-dao', 'dbs-utils']
},
'dbs-dao':
{
'srcdir': 'Server/Python/src',
'pythonmods': [],
'pythonpkg': ['dbs.dao',
'dbs.dao.Oracle',
'dbs.dao.Oracle.AcquisitionEra',
'dbs.dao.Oracle.ApplicationExecutable',
'dbs.dao.Oracle.AssociatedFile',
'dbs.dao.Oracle.Block',
'dbs.dao.Oracle.BlockParent',
'dbs.dao.Oracle.BlockSite',
'dbs.dao.Oracle.BranchHashe',
'dbs.dao.Oracle.Dataset',
'dbs.dao.Oracle.DatasetOutputMod_config',
'dbs.dao.Oracle.DatasetParent',
'dbs.dao.Oracle.DatasetRun',
'dbs.dao.Oracle.DatasetType',
'dbs.dao.Oracle.DataTier',
'dbs.dao.Oracle.DbsVersion',
'dbs.dao.Oracle.DoNothing',
'dbs.dao.Oracle.File',
'dbs.dao.Oracle.FileBuffer',
'dbs.dao.Oracle.FileLumi',
'dbs.dao.Oracle.FileOutputMod_config',
'dbs.dao.Oracle.FileParent',
'dbs.dao.Oracle.FileParentBlock',
'dbs.dao.Oracle.FileType',
'dbs.dao.Oracle.InsertTable',
'dbs.dao.Oracle.MigrationBlock',
'dbs.dao.Oracle.MigrationRequests',
'dbs.dao.Oracle.OutputModuleConfig',
'dbs.dao.Oracle.ParameterSetHashe',
'dbs.dao.Oracle.PhysicsGroup',
'dbs.dao.Oracle.PrimaryDataset',
'dbs.dao.Oracle.PrimaryDSType',
'dbs.dao.Oracle.ProcessedDataset',
'dbs.dao.Oracle.ProcessingEra',
'dbs.dao.Oracle.ReleaseVersion',
'dbs.dao.Oracle.Run',
'dbs.dao.Oracle.Service',
'dbs.dao.Oracle.Site'
],
'dependencies' : ['dbs-utils']
},
'dbs-utils':
{
'srcdir': 'Server/Python/src',
'pythonmods': [],
'pythonpkg': ['dbs.utils']
},
'LifeCycleTests':
{
'srcdir': 'SystemTests/src/python',
'bin': ['SystemTests/bin/dbs3BulkInsert.py',
'SystemTests/bin/dbs3CrabWorkflow.py',
'SystemTests/bin/dbs3Crab3Workflow.py',
'SystemTests/bin/dbs3dasComparision.py',
'SystemTests/bin/das_logfile_analyser.py',
'SystemTests/bin/das_logfile_parser.py',
'SystemTests/bin/dbs3DASAccess.py',
'SystemTests/bin/dbs3DASGetQueries.py',
'SystemTests/bin/dbs3IntroduceFailures.py',
'SystemTests/bin/dbs3GetBlocks.py',
'SystemTests/bin/dbs3GetDatasets.py',
'SystemTests/bin/dbs3GetFileLumis.py',
'SystemTests/bin/dbs3GetFileParents.py',
'SystemTests/bin/dbs3GetFiles.py',
'SystemTests/bin/dbs3MigrationService.py',
'SystemTests/bin/dbs3GetPrimaryDSType.py',
'SystemTests/bin/dbs3WriterStressTest.py',
'SystemTests/bin/getFakeData.py',
'SystemTests/bin/StatsServer.py',
'SystemTests/bin/run_job_wn.sh',
'SystemTests/bin/submit_jobs.sh'],
'pythonmods': ['LifeCycleTests.__init__'],
'pythonpkg': ['LifeCycleTests.LifeCycleTools'],
'conf' : ['SystemTests/conf/DBS3AnalysisLifecycle.conf',
'SystemTests/conf/DBS3BulkInsertLifecycle.conf',
'SystemTests/conf/DBS3MigrationService.conf',
'SystemTests/conf/PhedexDBSDASLifecylce.conf'],
'data' : ['SystemTests/data/dbs_queries_20120828.json']
},
'LifeCycleAnalysis':
{
'srcdir': 'SystemTests/src/python',
'bin': ['SystemTests/bin/LifeCyclePlots.py',
'SystemTests/bin/MergeDB.sh'],
'pythonmods': ['LifeCycleAnalysis.__init__'],
'pythonpkg': ['LifeCycleAnalysis.LifeCyclePlots']
}
}
def get_relative_path():
return os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), sys.argv[0])))
def process_dependencies(system):
srcdir = system['srcdir']
binaries = set(system.get('bin', set()))
examples = set(system.get('examples', set()))
configs = set(system.get('conf', set()))
data = set(system.get('data', set()))
statics = set(system.get('statics', set()))
pythonmods = set(system.get('pythonmods', set()))
pythonpkg = set(system.get('pythonpkg', set()))
dependencies = system.get('dependencies', [])
for dependency in dependencies:
dependant_system = systems[dependency]
if dependant_system['srcdir'] != srcdir:
print("Dependencies have to be in the same root directory")
sys.exit(1)
dependants = process_dependencies(dependant_system)
binaries.update(dependants.get('bin', set()))
examples.update(dependants.get('examples', set()))
configs.update(dependants.get('conf', set()))
data.update(dependants.get('data', set()))
statics.update(dependants.get('statics', set()))
pythonmods.update(dependants.get('pythonmods', set()))
pythonpkg.update(dependants.get('pythonpkg', set()))
return {'srcdir': srcdir,
'bin': list(binaries),
'examples': list(examples),
'conf': list(configs),
'data': list(data),
'statics': list(statics),
'pythonmods': list(pythonmods),
'pythonpkg': list(pythonpkg)}
def define_the_build(self, dist, system_name, run_make = True, patch_x = ''):
# Expand various sources.
docroot = "doc/build/html"
system = process_dependencies(systems[system_name])
exsrc = sum((glob("%s" % x) for x in system.get('examples', [])), [])
configs = sum((glob("%s" % x) for x in system.get('conf', [])), [])
data = sum((glob("%s" % x) for x in system.get('data', [])), [])
statics = sum((glob("%s" % x) for x in system.get('statics', [])), [])
binsrc = sum((glob("%s" % x) for x in system.get('bin', [])), [])
# Specify what to install.
py_version = (string.split(sys.version))[0]
pylibdir = '%slib/python%s/site-packages' % (patch_x, py_version[0:3])
dist.py_modules = system.get('pythonmods', [])
dist.packages = system.get('pythonpkg', [])
dist.package_dir = { '': system.get('srcdir', []) }
dist.data_files = [('examples', exsrc), ('%sbin' % patch_x, binsrc),
('conf', configs), ('data', data), ('statics', statics)]
for directory in set(os.path.dirname(path.replace('Client/utils/', '', 1)) for path in exsrc):
files = [x for x in exsrc if x.startswith('Client/utils/%s/' % directory)]
dist.data_files.append(('examples/%s' % (directory), files))
if os.path.exists(docroot):
for dirpath, dirs, files in os.walk(docroot):
dist.data_files.append(("%sdoc%s" % (patch_x, dirpath[len(docroot):]),
["%s/%s" % (dirpath, fname) for fname in files
if fname != '.buildinfo']))
class BuildCommand(Command):
"""Build python modules for a specific system."""
description = \
"Build python modules for the specified system. Possible\n" + \
"\t\t systems are 'dbs-web', 'dbs-client', 'pycurl-client' or 'dbs-migration'.\n" + \
"Use with --force to\n" + \
"\t\t ensure a clean build of only the requested parts.\n"
user_options = build.user_options
user_options.append(('system=', 's', 'build the specified system'))
def initialize_options(self):
self.system = None
def finalize_options(self):
# Check options.
if self.system == None:
print("System not specified, please use '-s dbs-web', '-s dbs-client', '-s pycurl-client' or '-s dbs-migration'")
sys.exit(1)
elif self.system not in systems:
print("System %s unrecognised, please use '-s dbs-web', '-s dbs-client', '-s pycurl-client' or \
'-s dbs-migration'" % self.system)
sys.exit(1)
# Expand various sources and maybe do the c++ build.
define_the_build(self, self.distribution, self.system, True, '')
# Force rebuild.
shutil.rmtree("%s/build" % get_relative_path(), True)
shutil.rmtree("doc/build", True)
def generate_docs(self):
if self.system=="dbs-web":
os.environ["PYTHONPATH"] = "%s/WMCore/build/lib/:%s" % (os.path.dirname(os.getcwd()), os.environ["PYTHONPATH"])
os.environ["PYTHONPATH"] = "%s/build/lib:%s" % (os.getcwd(), os.environ["PYTHONPATH"])
#spawn(['make', '-C', 'doc', 'html', 'PROJECT=%s' % self.system.lower()])
spawn(['make', '-C', 'doc', 'html', 'PROJECT=dbs'])
def run(self):
command = 'build'
if self.distribution.have_run.get(command): return
cmd = self.distribution.get_command_obj(command)
cmd.force = self.force
cmd.ensure_finalized()
cmd.run()
self.generate_docs()
self.distribution.have_run[command] = 1
class InstallCommand(install):
"""Install a specific system."""
description = \
"Install a specific system, either 'dbs-web', 'dbs-client', 'pycurl-client' or 'dbs-migration'. You can\n" + \
"\t\t patch an existing installation instead of normal full installation\n" + \
"\t\t using the '-p' option.\n"
user_options = install.user_options
user_options.append(('system=', 's', 'install the specified system'))
user_options.append(('patch', None, 'patch an existing installation'))
def initialize_options(self):
install.initialize_options(self)
self.system = None
self.patch = None
def finalize_options(self):
# Check options.
if self.system == None:
print("System not specified, please use '-s dbs-web', 'dbs-client', 'pycurl-client', 'dbs-migration',\
'LifeCycleTests' or 'LifeCycleAnalysis'")
sys.exit(1)
elif self.system not in systems:
print("System %s unrecognised, please use '-s dbs-web', 'dbs-client', 'pycurl-client', 'dbs-migration',\
'LifeCycleTests' or 'LifeCycleAnalysis'" % self.system)
sys.exit(1)
if self.patch and not os.path.isdir("%s/xbin" % self.prefix):
print("Patch destination %s does not look like a valid location." % self.prefix)
sys.exit(1)
# Expand various sources, but don't build anything from c++ now.
define_the_build(self, self.distribution, self.system,
False, (self.patch and 'x') or '')
# Whack the metadata name.
self.distribution.metadata.name = self.system
assert self.distribution.get_name() == self.system
# Pass to base class.
install.finalize_options(self)
# Mangle paths if we are patching. Most of the mangling occurs
# already in define_the_build(), but we need to fix up others.
if self.patch:
self.install_lib = re.sub(r'(.*)/lib/python(.*)', r'\1/xlib/python\2', self.install_lib)
self.install_scripts = re.sub(r'(.*)/bin$', r'\1/xbin', self.install_scripts)
def run(self):
for cmd_name in self.get_sub_commands():
cmd = self.distribution.get_command_obj(cmd_name)
cmd.distribution = self.distribution
if cmd_name == 'install_data':
cmd.install_dir = self.prefix
else:
cmd.install_dir = self.install_lib
cmd.ensure_finalized()
self.run_command(cmd_name)
self.distribution.have_run[cmd_name] = 1
setup(name = 'dbs',
version = '3.4.4',
maintainer_email = '[email protected]',
cmdclass = {'build_system': BuildCommand,
'install_system': InstallCommand})