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 @@ ...@@ -46,6 +46,11 @@
""".splitlines())) """.splitlines()))
BUILD_EXT_WARNING="""\ speedups = Feature(
WARNING: The C extension could not be compiled, speedups are not enabled. "options C speed-enhancement modules",
standard=True,
ext_modules = [
Extension("simplejson._speedups", ["simplejson/_speedups.c"]),
],
)
...@@ -51,6 +56,6 @@ ...@@ -51,6 +56,6 @@
Below is the output showing how the compilation failed: class BuildFailed(Exception):
""" pass
class ve_build_ext(build_ext): class ve_build_ext(build_ext):
# This class allows C extension building to fail. # This class allows C extension building to fail.
...@@ -59,9 +64,9 @@ ...@@ -59,9 +64,9 @@
try: try:
build_ext.run(self) build_ext.run(self)
except DistutilsPlatformError, x: except DistutilsPlatformError, x:
self._unavailable(x) raise BuildFailed()
def build_extension(self, ext): def build_extension(self, ext):
try: try:
build_ext.build_extension(self, ext) build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError), x: except (CCompilerError, DistutilsExecError), x:
...@@ -63,13 +68,7 @@ ...@@ -63,13 +68,7 @@
def build_extension(self, ext): def build_extension(self, ext):
try: try:
build_ext.build_extension(self, ext) build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError), x: except (CCompilerError, DistutilsExecError), x:
self._unavailable(x) raise BuildFailed()
def _unavailable(self, exc):
print '*'*70
print BUILD_EXT_WARNING
print exc
print '*'*70
...@@ -75,11 +74,9 @@ ...@@ -75,11 +74,9 @@
speedups = Feature( def run_setup(with_binary):
"options C speed-enhancement modules", if with_binary:
standard=True, features = {'speedups': speedups}
ext_modules = [ else:
Extension("simplejson._speedups", ["simplejson/_speedups.c"]), features = {}
],
)
setup( setup(
name="simplejson", name="simplejson",
...@@ -95,6 +92,6 @@ ...@@ -95,6 +92,6 @@
platforms=['any'], platforms=['any'],
test_suite="simplejson.tests", test_suite="simplejson.tests",
zip_safe=True, zip_safe=True,
features={'speedups': speedups}, features=features,
cmdclass={'build_ext': ve_build_ext}, cmdclass={'build_ext': ve_build_ext},
) )
...@@ -99,2 +96,19 @@ ...@@ -99,2 +96,19 @@
cmdclass={'build_ext': ve_build_ext}, 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