Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 296 lines (252 sloc) 9.875 kb
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
1 import glob
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
2 import os
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
3 import subprocess
4 import sys
5 import warnings
6
7 # Hack to silence atexit traceback in newer python versions.
db1eb3c5 »
2009-06-18 fix some things that broke Python 2.3 support since last I tried it
8 try:
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
9 import multiprocessing
10 except ImportError:
11 pass
12
13 try:
14 from ConfigParser import SafeConfigParser
15 except ImportError:
16 # PY3
17 from configparser import SafeConfigParser
18
19 # Don't force people to install distribute unless
20 # we have to.
21 try:
22 from setuptools import setup, Feature
23 except ImportError:
24 from distribute_setup import use_setuptools
25 use_setuptools()
26 from setuptools import setup, Feature
27
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
28 from distutils.cmd import Command
4f66ac7f »
2009-02-09 don't fail if the C extension fails to build
29 from distutils.command.build_ext import build_ext
30 from distutils.errors import CCompilerError
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
31 from distutils.errors import DistutilsPlatformError, DistutilsExecError
d953cf07 »
2009-02-02 really simple c extension module for bson - basically just experiment…
32 from distutils.core import Extension
ec01929e »
2009-01-22 starting on a setup.py
33
55d8e116 »
2012-05-01 Version -> +
34 version = "2.2+"
322a13d8 »
2009-05-12 move version from setup.py to pymongo.version
35
48b68aa6 »
2009-01-26 make sure to close the file
36 f = open("README.rst")
b7c4e002 »
2009-01-26 add classifiers and use the README as the long description
37 try:
f167101a »
2009-02-20 changes to support python 2.4
38 try:
39 readme_content = f.read()
40 except:
41 readme_content = ""
48b68aa6 »
2009-01-26 make sure to close the file
42 finally:
43 f.close()
b7c4e002 »
2009-01-26 add classifiers and use the README as the long description
44
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
45 PY3 = sys.version_info[0] == 3
46
47 nose_config_options = {
48 'with-xunit': '1', # Write out nosetests.xml for CI.
49 'py3where': 'build', # Tell nose where to find tests under PY3.
50 }
51
52 def write_nose_config():
53 """Write out setup.cfg. Since py3where has to be set
54 for tests to run correctly in Python 3 we create this
55 on the fly.
56 """
57 config = SafeConfigParser()
58 config.add_section('nosetests')
59 for opt, val in nose_config_options.items():
60 config.set('nosetests', opt, val)
61 try:
62 cf = open('setup.cfg', 'w')
63 config.write(cf)
64 finally:
65 cf.close()
66
67
68 def should_run_tests():
69 if "test" in sys.argv or "nosetests" in sys.argv:
70 return True
71 return False
72
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
73
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
74 class doc(Command):
75
76 description = "generate or test documentation"
77
78 user_options = [("test", "t",
79 "run doctests instead of generating documentation")]
80
81 boolean_options = ["test"]
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
82
83 def initialize_options(self):
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
84 self.test = False
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
85
86 def finalize_options(self):
87 pass
88
89 def run(self):
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
90 if self.test:
91 path = "doc/_build/doctest"
92 mode = "doctest"
93 else:
94 path = "doc/_build/%s" % version
95 mode = "html"
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
96
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
97 try:
98 os.makedirs(path)
99 except:
100 pass
96caf793 »
2009-04-14 clean out docs for version before generating new ones
101
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
102 status = subprocess.call(["sphinx-build", "-E",
103 "-b", mode, "doc", path])
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
104
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
105 if status:
106 raise RuntimeError("documentation step '%s' failed" % (mode,))
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
107
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
108 sys.stdout.write("\nDocumentation step '%s' performed, results here:\n"
109 " %s/\n" % (mode, path))
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
110
6176981d »
2009-12-09 add `setup.py doc --test` to run doctests
111
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
112 if sys.platform == 'win32' and sys.version_info > (2, 6):
2ed05bec »
2011-04-06 PEP8 cleanups.
113 # 2.6's distutils.msvc9compiler can raise an IOError when failing to
114 # find the compiler
115 build_errors = (CCompilerError, DistutilsExecError,
116 DistutilsPlatformError, IOError)
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
117 else:
2ed05bec »
2011-04-06 PEP8 cleanups.
118 build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
119
120
4f66ac7f »
2009-02-09 don't fail if the C extension fails to build
121 class custom_build_ext(build_ext):
122 """Allow C extension building to fail.
123
124 The C extension speeds up BSON encoding, but is not essential.
125 """
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
126
127 warning_message = """
b927d645 »
2012-04-22 Updated build/install/release docs.
128 ********************************************************************
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
129 WARNING: %s could not
130 be compiled. No C extensions are essential for PyMongo to run,
131 although they do result in significant speed improvements.
132
68abd1a8 »
2011-04-07 Document C extension dependencies PYTHON-235
133 If you are seeing this message on Linux you probably need to
e6170131 »
2011-05-06 Document build deps for popular distros PYTHON-235
134 install GCC and/or the Python development package for your
b927d645 »
2012-04-22 Updated build/install/release docs.
135 version of Python.
e6170131 »
2011-05-06 Document build deps for popular distros PYTHON-235
136
b927d645 »
2012-04-22 Updated build/install/release docs.
137 Debian and Ubuntu users should issue the following command:
138
139 $ sudo apt-get install build-essential python-dev
140
141 RedHat, CentOS, and Fedora users should issue the following command:
142
143 $ sudo yum install gcc python-devel
68abd1a8 »
2011-04-07 Document C extension dependencies PYTHON-235
144
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
145 %s
b927d645 »
2012-04-22 Updated build/install/release docs.
146 ********************************************************************
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
147 """
148
149 def run(self):
150 try:
151 build_ext.run(self)
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
152 except DistutilsPlatformError:
153 e = sys.exc_info()[1]
154 sys.stdout.write('%s\n' % str(e))
155 warnings.warn(self.warning_message % ("Extension modules",
156 "There was an issue with "
157 "your platform configuration"
158 " - see above."))
159
160 def set_nose_options(self):
161 # Under python 3 we need to tell nose where to find the
162 # proper tests. if we built the C extensions this will be
163 # someplace like build/lib.<os>-<arch>-<python version>
164 if PY3:
165 ver = '.'.join(map(str, sys.version_info[:2]))
79d66f32 »
2012-03-29 Fix testing issue.
166 lib_dirs = glob.glob(os.path.join('build', 'lib*' + ver))
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
167 if lib_dirs:
168 nose_config_options['py3where'] = lib_dirs[0]
169 write_nose_config()
76e00a06 »
2009-06-03 update extension building to hopefully detect more types of failed bu…
170
4f66ac7f »
2009-02-09 don't fail if the C extension fails to build
171 def build_extension(self, ext):
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
172 name = ext.name
7bbb4a51 »
2009-02-20 python 2.3 support
173 if sys.version_info[:3] >= (2, 4, 0):
174 try:
175 build_ext.build_extension(self, ext)
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
176 if should_run_tests():
177 self.set_nose_options()
178 except build_errors:
179 e = sys.exc_info()[1]
180 sys.stdout.write('%s\n' % str(e))
181 warnings.warn(self.warning_message % ("The %s extension "
182 "module" % (name,),
183 "Above is the ouput "
184 "showing how the "
185 "compilation failed."))
7bbb4a51 »
2009-02-20 python 2.3 support
186 else:
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
187 warnings.warn(self.warning_message % ("The %s extension "
188 "module" % (name,),
189 "Please use Python >= 2.4 "
190 "to take advantage of the "
191 "extension."))
4f66ac7f »
2009-02-09 don't fail if the C extension fails to build
192
43213deb »
2009-05-08 suppport --no_ext command line option to not build c extension at all
193 c_ext = Feature(
789296c6 »
2010-09-13 Split C extension in two (pymongo, bson) PYTHON-60
194 "optional C extensions",
43213deb »
2009-05-08 suppport --no_ext command line option to not build c extension at all
195 standard=True,
789296c6 »
2010-09-13 Split C extension in two (pymongo, bson) PYTHON-60
196 ext_modules=[Extension('bson._cbson',
197 include_dirs=['bson'],
198 sources=['bson/_cbsonmodule.c',
199 'bson/time64.c',
56699b9f »
2010-09-14 switch to using buffer.c/h from Ruby
200 'bson/buffer.c',
789296c6 »
2010-09-13 Split C extension in two (pymongo, bson) PYTHON-60
201 'bson/encoding_helpers.c']),
202 Extension('pymongo._cmessage',
eea654ce »
2010-09-14 minor: we don't have any includes in the pymongo directory
203 include_dirs=['bson'],
b7518537 »
2010-09-14 minor: cleanup
204 sources=['pymongo/_cmessagemodule.c',
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
205 'bson/buffer.c'])])
43213deb »
2009-05-08 suppport --no_ext command line option to not build c extension at all
206
207 if "--no_ext" in sys.argv:
208 sys.argv = [x for x in sys.argv if x != "--no_ext"]
209 features = {}
527b530b »
2011-09-19 Don't try to build C extensions for PyPy/Jython.
210 elif (sys.platform.startswith("java") or
211 sys.platform == "cli" or
212 "PyPy" in sys.version):
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
213 sys.stdout.write("""
214 *****************************************************\n
215 The optional C extensions are currently not supported\n
216 by this python implementation.\n
217 *****************************************************\n
218 """)
527b530b »
2011-09-19 Don't try to build C extensions for PyPy/Jython.
219 features = {}
fdba7b4f »
2010-06-04 don't attempt to build C ext on big endian PYTHON-128
220 elif sys.byteorder == "big":
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
221 sys.stdout.write("""
222 *****************************************************\n
223 The optional C extensions are currently not supported\n
224 on big endian platforms and will not be built.\n
225 Performance may be degraded.\n
226 *****************************************************\n
227 """)
fdba7b4f »
2010-06-04 don't attempt to build C ext on big endian PYTHON-128
228 features = {}
43213deb »
2009-05-08 suppport --no_ext command line option to not build c extension at all
229 else:
230 features = {"c-ext": c_ext}
231
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
232 extra_opts = {
233 "packages": ["bson", "pymongo", "gridfs"],
234 "test_suite": "nose.collector"
235 }
236 if PY3:
237 extra_opts["use_2to3"] = True
238 if should_run_tests():
239 # Distribute isn't smart enough to copy the
240 # tests and run 2to3 on them. We don't want to
241 # install the test suite so only do this if we
242 # are testing.
243 # https://bitbucket.org/tarek/distribute/issue/233
244 extra_opts["packages"].append("test")
245 # Hack to make "python3.x setup.py nosetests" work in python 3
246 # otherwise it won't run 2to3 before running the tests.
247 if "nosetests" in sys.argv:
248 sys.argv.remove("nosetests")
249 sys.argv.append("test")
250 # All "nosetests" does is import and run nose.main.
251 extra_opts["test_suite"] = "nose.main"
252
79d66f32 »
2012-03-29 Fix testing issue.
253 # This may be called a second time if
254 # we are testing with C extensions.
255 if should_run_tests():
256 write_nose_config()
257
ec01929e »
2009-01-22 starting on a setup.py
258 setup(
259 name="pymongo",
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
260 version=version,
fa908220 »
2009-05-13 update description
261 description="Python driver for MongoDB <http://www.mongodb.org>",
b7c4e002 »
2009-01-26 add classifiers and use the README as the long description
262 long_description=readme_content,
9f0a7b64 »
2009-09-16 BUMP 0.16 support encoding uuid.UUID instances, fix for explain with …
263 author="Mike Dirolf",
41d0dbaf »
2011-03-21 Fix some build/dist warnings.
264 author_email="mongodb-user@googlegroups.com",
8fd90457 »
2011-03-18 Make myself maintainer.
265 maintainer="Bernie Hackett",
266 maintainer_email="bernie@10gen.com",
ec01929e »
2009-01-22 starting on a setup.py
267 url="http://github.com/mongodb/mongo-python-driver",
a650e4bc »
2010-09-14 add keyword
268 keywords=["mongo", "mongodb", "pymongo", "gridfs", "bson"],
54be5db8 »
2010-01-05 removing all support for mongo-qa tests
269 install_requires=[],
43213deb »
2009-05-08 suppport --no_ext command line option to not build c extension at all
270 features=features,
c2c35cf4 »
2009-01-22 more metadata
271 license="Apache License, Version 2.0",
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
272 tests_require=["nose"],
b7c4e002 »
2009-01-26 add classifiers and use the README as the long description
273 classifiers=[
9f0a7b64 »
2009-09-16 BUMP 0.16 support encoding uuid.UUID instances, fix for explain with …
274 "Development Status :: 5 - Production/Stable",
b7c4e002 »
2009-01-26 add classifiers and use the README as the long description
275 "Intended Audience :: Developers",
276 "License :: OSI Approved :: Apache Software License",
277 "Operating System :: MacOS :: MacOS X",
278 "Operating System :: Microsoft :: Windows",
279 "Operating System :: POSIX",
5f8765a0 »
2012-05-01 Update trove classifiers for various python3 lists
280 "Programming Language :: Python :: 2",
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
281 "Programming Language :: Python :: 2.4",
282 "Programming Language :: Python :: 2.5",
283 "Programming Language :: Python :: 2.6",
284 "Programming Language :: Python :: 2.7",
5f8765a0 »
2012-05-01 Update trove classifiers for various python3 lists
285 "Programming Language :: Python :: 3",
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
286 "Programming Language :: Python :: 3.1",
287 "Programming Language :: Python :: 3.2",
288 "Programming Language :: Python :: Implementation :: CPython",
289 "Programming Language :: Python :: Implementation :: Jython",
290 "Programming Language :: Python :: Implementation :: PyPy",
4f66ac7f »
2009-02-09 don't fail if the C extension fails to build
291 "Topic :: Database"],
12449c65 »
2009-04-14 add target for setup.py to generate versioned docs: python setup.py doc
292 cmdclass={"build_ext": custom_build_ext,
96b133cb »
2012-03-28 Python 3 setup.py changes PYTHON-84
293 "doc": doc},
294 **extra_opts
295 )
Something went wrong with that request. Please try again.