ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DAS/setup.py
Revision: 1.6
Committed: Fri Apr 2 14:01:29 2010 UTC (15 years ago) by valya
Content type: text/x-python
Branch: MAIN
Changes since 1.5: +3 -10 lines
Log Message:
Use DAS.version instead of hardcoded name

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