Skip to content
Snippets Groups Projects
Commit 7e939099d1d8 authored by Bob Ippolito's avatar Bob Ippolito
Browse files

fix setup.py to build without a compiler

git-svn-id: http://simplejson.googlecode.com/svn/trunk@96 a4795897-2c25-0410-b006-0d3caba88fa1
parent 5db2cd507210
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,11 @@
""".splitlines()))
BUILD_EXT_WARNING="""\
WARNING: The C extension could not be compiled, speedups are not enabled.
speedups = Feature(
"options C speed-enhancement modules",
standard=True,
ext_modules = [
Extension("simplejson._speedups", ["simplejson/_speedups.c"]),
],
)
......@@ -51,6 +56,6 @@
Below is the output showing how the compilation failed:
"""
class BuildFailed(Exception):
pass
class ve_build_ext(build_ext):
# This class allows C extension building to fail.
......@@ -59,9 +64,9 @@
try:
build_ext.run(self)
except DistutilsPlatformError, x:
self._unavailable(x)
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError), x:
......@@ -63,13 +68,7 @@
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError), x:
self._unavailable(x)
def _unavailable(self, exc):
print '*'*70
print BUILD_EXT_WARNING
print exc
print '*'*70
raise BuildFailed()
......@@ -75,11 +74,9 @@
speedups = Feature(
"options C speed-enhancement modules",
standard=True,
ext_modules = [
Extension("simplejson._speedups", ["simplejson/_speedups.c"]),
],
)
def run_setup(with_binary):
if with_binary:
features = {'speedups': speedups}
else:
features = {}
setup(
name="simplejson",
......@@ -95,6 +92,6 @@
platforms=['any'],
test_suite="simplejson.tests",
zip_safe=True,
features={'speedups': speedups},
features=features,
cmdclass={'build_ext': ve_build_ext},
)
......@@ -99,2 +96,19 @@
cmdclass={'build_ext': ve_build_ext},
)
try:
run_setup(True)
except BuildFailed:
BUILD_EXT_WARNING = "WARNING: The C extension could not be compiled, speedups are not enabled."
print '*' * 75
print BUILD_EXT_WARNING
print "Failure information, if any, is above."
print "I'm retrying the build without the C extension now."
print '*' * 75
run_setup(False)
print '*' * 75
print BUILD_EXT_WARNING
print "Plain-Python installation succeeded."
print '*' * 75
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment