ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DAS/setup.py
Revision: 1.3
Committed: Mon Feb 8 15:16:25 2010 UTC (15 years, 2 months ago) by valya
Content type: text/x-python
Branch: MAIN
CVS Tags: V04_00_05, V04_00_04, V04_00_03, V04_00_02, V04_00_01, V04_00_00
Changes since 1.2: +5 -15 lines
Log Message:
One more revision

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