ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DAS/setup.py
Revision: 1.2
Committed: Sat Feb 6 01:42:54 2010 UTC (15 years, 2 months ago) by valya
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +81 -35 lines
Log Message:
Redo setup.py

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     ext_modules=[Extension('extensions.das_speed_utils',
76     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     package_dir = {'DAS': 'src/python/DAS',
99     'core': 'src/python/DAS/core',
100     'extensions': 'src/python/DAS/extensions',
101     'services': 'src/python/DAS/services',
102     'tools': 'src/python/DAS/tools',
103     'utils': 'src/python/DAS/utils',
104     'web': 'src/python/DAS/web'}
105     package_data = {
106     'src': ['python/DAS/services/maps/*.yml'],
107     }
108     #data_files = [
109     # ('src/js', ['src/js/ajax_utils.js', 'src/js/prototype.js', 'src/js/utils.js']),
110     # ('css', ['src/css/*.css']),
111     # ('templates', ['src/templates/*.tmpl']),
112     #]
113     packages = find_packages('src/python/DAS')
114     packages += ['src/css', 'src/js', 'src/templates', 'etc', 'bin', 'test', 'doc']
115     license = "CMS experiment software"
116     classifiers = [
117     "Development Status :: 3 - Production/Beta",
118     "Intended Audience :: Developers",
119     "License :: OSI Approved :: CMS/CERN Software License",
120     "Operating System :: MacOS :: MacOS X",
121     "Operating System :: Microsoft :: Windows",
122     "Operating System :: POSIX",
123     "Programming Language :: Python",
124     "Topic :: Database"
125     ]
126    
127     def main():
128     if sys.version < required_python_version:
129     s = "I'm sorry, but %s %s requires Python %s or later."
130     print s % (name, version, required_python_version)
131     sys.exit(1)
132    
133     # set default location for "data_files" to
134     # platform specific "site-packages" location
135     for scheme in INSTALL_SCHEMES.values():
136     scheme['data'] = scheme['purelib']
137    
138     dist = setup(
139     name = name,
140     version = version,
141     description = description,
142     long_description = readme,
143     keywords = keywords,
144     package_dir = package_dir,
145     packages = packages,
146     package_data = package_data,
147     # data_files = data_files,
148     include_package_data = True,
149     install_requires = requirements,
150     # scripts = scriptfiles,
151     features = features,
152     classifiers = classifiers,
153     cmdclass = {"build_ext": custom_build_ext},
154     author = author,
155     author_email = author_email,
156     url = url,
157     license = license,
158     )
159    
160     if __name__ == "__main__":
161     main()
162