00001
00002
00003 import sys
00004 import os
00005 try:
00006 import subprocess
00007 has_subprocess = True
00008 except:
00009 has_subprocess = False
00010 import shutil
00011
00012 from ez_setup import use_setuptools
00013 use_setuptools()
00014 from setuptools import setup
00015 from setuptools import Feature
00016 from distutils.cmd import Command
00017 from distutils.command.build_ext import build_ext
00018 from distutils.errors import CCompilerError
00019 from distutils.errors import DistutilsPlatformError, DistutilsExecError
00020 from distutils.core import Extension
00021
00022
00023 version = "1.10"
00024
00025 f = open("README.rst")
00026 try:
00027 try:
00028 readme_content = f.read()
00029 except:
00030 readme_content = ""
00031 finally:
00032 f.close()
00033
00034
00035 class doc(Command):
00036
00037 description = "generate or test documentation"
00038
00039 user_options = [("test", "t",
00040 "run doctests instead of generating documentation")]
00041
00042 boolean_options = ["test"]
00043
00044 def initialize_options(self):
00045 self.test = False
00046
00047 def finalize_options(self):
00048 pass
00049
00050 def run(self):
00051 if self.test:
00052 path = "doc/_build/doctest"
00053 mode = "doctest"
00054 else:
00055 path = "doc/_build/%s" % version
00056 mode = "html"
00057
00058
00059 try:
00060 os.makedirs(path)
00061 except:
00062 pass
00063
00064 if has_subprocess:
00065 status = subprocess.call(["sphinx-build", "-b", mode, "doc", path])
00066
00067 if status:
00068 raise RuntimeError("documentation step '%s' failed" % mode)
00069
00070 print ""
00071 print "Documentation step '%s' performed, results here:" % mode
00072 print " %s/" % path
00073 else:
00074 print """
00075 `setup.py doc` is not supported for this version of Python.
00076
00077 Please ask in the user forums for help.
00078 """
00079
00080
00081 if sys.platform == 'win32' and sys.version_info > (2, 6):
00082
00083
00084 build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
00085 IOError)
00086 else:
00087 build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
00088
00089
00090 class custom_build_ext(build_ext):
00091 """Allow C extension building to fail.
00092
00093 The C extension speeds up BSON encoding, but is not essential.
00094 """
00095
00096 warning_message = """
00097 **************************************************************
00098 WARNING: %s could not
00099 be compiled. No C extensions are essential for PyMongo to run,
00100 although they do result in significant speed improvements.
00101
00102 %s
00103 **************************************************************
00104 """
00105
00106 def run(self):
00107 try:
00108 build_ext.run(self)
00109 except DistutilsPlatformError, e:
00110 print e
00111 print self.warning_message % ("Extension modules",
00112 "There was an issue with your "
00113 "platform configuration - see above.")
00114
00115 def build_extension(self, ext):
00116 if sys.version_info[:3] >= (2, 4, 0):
00117 try:
00118 build_ext.build_extension(self, ext)
00119 except build_errors:
00120 print self.warning_message % ("The %s extension module" % ext.name,
00121 "Above is the ouput showing how "
00122 "the compilation failed.")
00123 else:
00124 print self.warning_message % ("The %s extension module" % ext.name,
00125 "Please use Python >= 2.4 to take "
00126 "advantage of the extension.")
00127
00128 c_ext = Feature(
00129 "optional C extensions",
00130 standard=True,
00131 ext_modules=[Extension('bson._cbson',
00132 include_dirs=['bson'],
00133 sources=['bson/_cbsonmodule.c',
00134 'bson/time64.c',
00135 'bson/buffer.c',
00136 'bson/encoding_helpers.c']),
00137 Extension('pymongo._cmessage',
00138 include_dirs=['bson'],
00139 sources=['pymongo/_cmessagemodule.c',
00140 'bson/_cbsonmodule.c',
00141 'bson/time64.c',
00142 'bson/buffer.c',
00143 'bson/encoding_helpers.c'])])
00144
00145 if "--no_ext" in sys.argv:
00146 sys.argv = [x for x in sys.argv if x != "--no_ext"]
00147 features = {}
00148 elif sys.byteorder == "big":
00149 print """
00150 *****************************************************
00151 The optional C extensions are currently not supported
00152 on big endian platforms and will not be built.
00153 Performance may be degraded.
00154 *****************************************************
00155 """
00156 features = {}
00157 else:
00158 features = {"c-ext": c_ext}
00159
00160 setup(
00161 name="pymongo",
00162 version=version,
00163 description="Python driver for MongoDB <http://www.mongodb.org>",
00164 long_description=readme_content,
00165 author="Mike Dirolf",
00166 author_email="mongodb-user@googlegroups.com",
00167 maintainer="Bernie Hackett",
00168 maintainer_email="bernie@10gen.com",
00169 url="http://github.com/mongodb/mongo-python-driver",
00170 keywords=["mongo", "mongodb", "pymongo", "gridfs", "bson"],
00171 packages=["bson", "pymongo", "gridfs"],
00172 install_requires=[],
00173 features=features,
00174 license="Apache License, Version 2.0",
00175 test_suite="nose.collector",
00176 classifiers=[
00177 "Development Status :: 5 - Production/Stable",
00178 "Intended Audience :: Developers",
00179 "License :: OSI Approved :: Apache Software License",
00180 "Operating System :: MacOS :: MacOS X",
00181 "Operating System :: Microsoft :: Windows",
00182 "Operating System :: POSIX",
00183 "Programming Language :: Python",
00184 "Topic :: Database"],
00185 cmdclass={"build_ext": custom_build_ext,
00186 "doc": doc})