OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 from ez_setup import use_setuptools |
| 4 import sys |
| 5 if 'cygwin' in sys.platform.lower(): |
| 6 min_version='0.6c6' |
| 7 else: |
| 8 min_version='0.6a9' |
| 9 try: |
| 10 use_setuptools(min_version=min_version) |
| 11 except TypeError: |
| 12 # If a non-local ez_setup is already imported, it won't be able to |
| 13 # use the min_version kwarg and will bail with TypeError |
| 14 use_setuptools() |
| 15 |
| 16 from setuptools import setup, find_packages, Extension, Feature |
| 17 from distutils.command.build_ext import build_ext |
| 18 from distutils.errors import CCompilerError, DistutilsExecError, \ |
| 19 DistutilsPlatformError |
| 20 |
| 21 VERSION = '2.0.9' |
| 22 DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" |
| 23 LONG_DESCRIPTION = """ |
| 24 simplejson is a simple, fast, complete, correct and extensible |
| 25 JSON <http://json.org> encoder and decoder for Python 2.4+. It is |
| 26 pure Python code with no dependencies, but includes an optional C |
| 27 extension for a serious speed boost. |
| 28 |
| 29 simplejson was formerly known as simple_json, but changed its name to |
| 30 comply with PEP 8 module naming guidelines. |
| 31 |
| 32 The encoder may be subclassed to provide serialization in any kind of |
| 33 situation, without any special support by the objects to be serialized |
| 34 (somewhat like pickle). |
| 35 |
| 36 The decoder can handle incoming JSON strings of any specified encoding |
| 37 (UTF-8 by default). |
| 38 """ |
| 39 |
| 40 CLASSIFIERS = filter(None, map(str.strip, |
| 41 """ |
| 42 Intended Audience :: Developers |
| 43 License :: OSI Approved :: MIT License |
| 44 Programming Language :: Python |
| 45 Topic :: Software Development :: Libraries :: Python Modules |
| 46 """.splitlines())) |
| 47 |
| 48 |
| 49 speedups = Feature( |
| 50 "options C speed-enhancement modules", |
| 51 standard=True, |
| 52 ext_modules = [ |
| 53 Extension("simplejson._speedups", ["simplejson/_speedups.c"]), |
| 54 ], |
| 55 ) |
| 56 |
| 57 if sys.platform == 'win32' and sys.version_info > (2, 6): |
| 58 # 2.6's distutils.msvc9compiler can raise an IOError when failing to |
| 59 # find the compiler |
| 60 ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, |
| 61 IOError) |
| 62 else: |
| 63 ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) |
| 64 |
| 65 class BuildFailed(Exception): |
| 66 pass |
| 67 |
| 68 class ve_build_ext(build_ext): |
| 69 # This class allows C extension building to fail. |
| 70 |
| 71 def run(self): |
| 72 try: |
| 73 build_ext.run(self) |
| 74 except DistutilsPlatformError, x: |
| 75 raise BuildFailed() |
| 76 |
| 77 def build_extension(self, ext): |
| 78 try: |
| 79 build_ext.build_extension(self, ext) |
| 80 except ext_errors, x: |
| 81 raise BuildFailed() |
| 82 |
| 83 def run_setup(with_binary): |
| 84 if with_binary: |
| 85 features = {'speedups': speedups} |
| 86 else: |
| 87 features = {} |
| 88 |
| 89 setup( |
| 90 name="simplejson", |
| 91 version=VERSION, |
| 92 description=DESCRIPTION, |
| 93 long_description=LONG_DESCRIPTION, |
| 94 classifiers=CLASSIFIERS, |
| 95 author="Bob Ippolito", |
| 96 author_email="bob@redivi.com", |
| 97 url="http://undefined.org/python/#simplejson", |
| 98 license="MIT License", |
| 99 packages=find_packages(exclude=['ez_setup']), |
| 100 platforms=['any'], |
| 101 test_suite="simplejson.tests", |
| 102 zip_safe=True, |
| 103 features=features, |
| 104 cmdclass={'build_ext': ve_build_ext}, |
| 105 ) |
| 106 |
| 107 try: |
| 108 run_setup(True) |
| 109 except BuildFailed: |
| 110 BUILD_EXT_WARNING = "WARNING: The C extension could not be compiled, speedup
s are not enabled." |
| 111 print '*' * 75 |
| 112 print BUILD_EXT_WARNING |
| 113 print "Failure information, if any, is above." |
| 114 print "I'm retrying the build without the C extension now." |
| 115 print '*' * 75 |
| 116 |
| 117 run_setup(False) |
| 118 |
| 119 print '*' * 75 |
| 120 print BUILD_EXT_WARNING |
| 121 print "Plain-Python installation succeeded." |
| 122 print '*' * 75 |
OLD | NEW |