ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DAS/setup.py
Revision: 1.7
Committed: Fri Apr 2 14:43:52 2010 UTC (15 years ago) by valya
Content type: text/x-python
Branch: MAIN
CVS Tags: V04_00_07
Changes since 1.6: +1 -0 lines
Log Message:
Added location of src/python to find DAS, since our current dir is not python module

File Contents

# User Rev Content
1 valya 1.1 #!/usr/bin/env python
2    
3     import sys
4     import os
5    
6     from ez_setup import use_setuptools
7     use_setuptools()
8     from setuptools import setup, find_packages, Feature
9     from distutils.cmd import Command
10     from distutils.command.build_ext import build_ext
11     from distutils.errors import CCompilerError
12     from distutils.errors import DistutilsPlatformError, DistutilsExecError
13     from distutils.core import Extension
14 valya 1.2 from distutils.command.install import INSTALL_SCHEMES
15 valya 1.6
16 valya 1.7 sys.path.append(os.path.join(os.getcwd(), 'src/python'))
17 valya 1.6 from DAS import version as das_version
18 valya 1.1
19     requirements = []
20     try:
21     import xml.etree.cElementTree
22     except ImportError:
23     try:
24     import celementtree
25     except ImportError:
26     requirements.append("celementtree")
27     try:
28     import pymongo
29     except ImportError:
30     requirements.append("pymongo")
31    
32 valya 1.2 required_python_version = '2.6'
33    
34 valya 1.1 if sys.platform == 'win32' and sys.version_info > (2, 6):
35     # 2.6's distutils.msvc9compiler can raise an IOError when failing to
36     # find the compiler
37     build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
38     IOError)
39     else:
40     build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
41    
42    
43     class custom_build_ext(build_ext):
44     """Allow C extension building to fail.
45     The C extension speeds up DAS, but is not essential.
46     """
47    
48     warning_message = """
49     **************************************************************
50     WARNING: %s could not
51     be compiled. No C extensions are essential for DAS to run,
52     although they do result in significant speed improvements.
53    
54     %s
55     **************************************************************
56     """
57    
58     def run(self):
59     try:
60     build_ext.run(self)
61     except DistutilsPlatformError, e:
62     print e
63     print self.warning_message % ("Extension modules",
64     "There was an issue with your "
65     "platform configuration - see above.")
66    
67     def build_extension(self, ext):
68     try:
69     build_ext.build_extension(self, ext)
70     except build_errors:
71     print self.warning_message % ("The %s extension module" % ext.name,
72     "Above is the ouput showing how "
73     "the compilation failed.")
74    
75     c_ext = Feature(
76     "optional C extension",
77     standard=True,
78 valya 1.3 ext_modules=[Extension('DAS.extensions.das_speed_utils',
79 valya 1.1 include_dirs=['extensions'],
80     sources=['src/python/DAS/extensions/dict_handler.c'])])
81    
82     if "--no_ext" in sys.argv:
83     sys.argv = [x for x in sys.argv if x != "--no_ext"]
84     features = {}
85     else:
86     features = {"c-ext": c_ext}
87    
88 valya 1.6 version = das_version
89 valya 1.2 name = "DAS"
90     description = "CMS Data Aggregation System"
91     readme ="""
92     DAS stands for Data Aggregation System
93     <https://twiki.cern.ch/twiki/bin/viewauth/CMS/DMWMDataAggregationService>
94     """
95     author = "Valentin Kuznetsov",
96     author_email = "vkuznet@gmail.com",
97     scriptfiles = filter(os.path.isfile, ['etc/das.cfg'])
98     url = "https://twiki.cern.ch/twiki/bin/viewauth/CMS/DMWMDataAggregationService",
99     keywords = ["DAS", "Aggregation", "Meta-data"]
100 valya 1.3 package_dir = {'DAS': 'src/python/DAS'}
101 valya 1.2 package_data = {
102 valya 1.3 'src': ['python/DAS/services/maps/*.yml', 'python/DAS/web/css/*.css'],
103 valya 1.2 }
104 valya 1.3 #packages = find_packages('src/python/DAS')
105     packages = find_packages('src/python/')
106 valya 1.2 packages += ['src/css', 'src/js', 'src/templates', 'etc', 'bin', 'test', 'doc']
107     license = "CMS experiment software"
108     classifiers = [
109     "Development Status :: 3 - Production/Beta",
110     "Intended Audience :: Developers",
111     "License :: OSI Approved :: CMS/CERN Software License",
112     "Operating System :: MacOS :: MacOS X",
113     "Operating System :: Microsoft :: Windows",
114     "Operating System :: POSIX",
115     "Programming Language :: Python",
116     "Topic :: Database"
117     ]
118    
119     def main():
120     if sys.version < required_python_version:
121     s = "I'm sorry, but %s %s requires Python %s or later."
122     print s % (name, version, required_python_version)
123     sys.exit(1)
124    
125     # set default location for "data_files" to
126     # platform specific "site-packages" location
127     for scheme in INSTALL_SCHEMES.values():
128     scheme['data'] = scheme['purelib']
129    
130     dist = setup(
131     name = name,
132     version = version,
133     description = description,
134     long_description = readme,
135     keywords = keywords,
136     package_dir = package_dir,
137     packages = packages,
138     package_data = package_data,
139     # data_files = data_files,
140     include_package_data = True,
141     install_requires = requirements,
142     # scripts = scriptfiles,
143     features = features,
144     classifiers = classifiers,
145     cmdclass = {"build_ext": custom_build_ext},
146     author = author,
147     author_email = author_email,
148     url = url,
149     license = license,
150     )
151    
152     if __name__ == "__main__":
153     main()
154