ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DAS/setup.py
Revision: 1.9
Committed: Fri Apr 30 16:44:44 2010 UTC (15 years ago) by valya
Content type: text/x-python
Branch: MAIN
CVS Tags: V0_4_10_pre1, V0_4_9, HEAD
Changes since 1.8: +1 -1 lines
Log Message:
Update required pymongo version

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