forked from dmwm/WMCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
115 lines (94 loc) · 3.76 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
#!/usr/bin/env python
"""
Build, clean and test the WMCore package.
"""
from distutils.core import setup, Command
from distutils.util import get_platform
from glob import glob
from os.path import splitext, basename, join as pjoin, walk
from ConfigParser import ConfigParser, NoOptionError
import os, sys, os.path
import unittest
import time
from setup_build import BuildCommand, InstallCommand
from setup_build import get_path_to_wmcore_root, list_packages, list_static_files
from setup_test import LintCommand, ReportCommand, CoverageCommand, TestCommand
from setup_dependencies import dependencies
class CleanCommand(Command):
description = "Clean up (delete) compiled files"
user_options = [ ]
def initialize_options(self):
self._clean_me = [ ]
for root, dirs, files in os.walk('.'):
for f in files:
if f.endswith('.pyc'):
self._clean_me.append(pjoin(root, f))
def finalize_options(self):
pass
def run(self):
for clean_me in self._clean_me:
try:
os.unlink(clean_me)
except:
pass
class EnvCommand(Command):
description = "Configure the PYTHONPATH, DATABASE and PATH variables to" +\
"some sensible defaults, if not already set. Call with -q when eval-ing," +\
""" e.g.:
eval `python setup.py -q env`
"""
user_options = [ ]
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
if not os.getenv('DATABASE', False):
# Use an in memory sqlite one if none is configured.
print 'export DATABASE=sqlite://'
if not os.getenv('COUCHURL', False):
# Use the default localhost URL if none is configured.
print 'export COUCHURL=http://localhost:5984'
here = get_path_to_wmcore_root()
tests = here + '/test/python'
source = here + '/src/python'
# Stuff we want on the path
exepth = [source + '/WMCore/WebTools',
here + '/bin']
pypath=os.getenv('PYTHONPATH', '').strip(':').split(':')
for pth in [tests, source]:
if pth not in pypath:
pypath.append(pth)
# We might want to add other executables to PATH
expath=os.getenv('PATH', '').split(':')
for pth in exepth:
if pth not in expath:
expath.append(pth)
print 'export PYTHONPATH=%s' % ':'.join(pypath)
print 'export PATH=%s' % ':'.join(expath)
#We want the WMCORE root set, too
print 'export WMCORE_ROOT=%s' % get_path_to_wmcore_root()
print 'export WMCOREBASE=$WMCORE_ROOT'
print 'export WTBASE=$WMCORE_ROOT/src'
# The actual setup command, and the classes associated to the various options
# Need all the packages we want to build by default, this will be overridden in sub-system builds.
# Since it's a lot of code determine it by magic.
default_packages = list_packages(['src/python/WMCore',
'src/python/WMComponent',
'src/python/WMQuality',
'src/python/PSetTweaks'])
setup (name = 'wmcore',
version = '1.0',
maintainer_email = '[email protected]',
cmdclass = {'deep_clean': CleanCommand,
'lint': LintCommand,
'report': ReportCommand,
'coverage': CoverageCommand ,
'test' : TestCommand,
'env': EnvCommand,
'build_system': BuildCommand,
'install_system': InstallCommand },
# base directory for all our packages
package_dir = {'': 'src/python/'},# % get_path_to_wmcore_root()},
packages = default_packages,
data_files = list_static_files())