Created
December 3, 2012 21:02
-
-
Save dkuebric/4198006 to your computer and use it in GitHub Desktop.
oboeware os x patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/oboe/__init__.py b/oboe/__init__.py | |
index ab4d176..45f7a2d 100644 | |
--- a/oboe/__init__.py | |
+++ b/oboe/__init__.py | |
@@ -3,8 +3,6 @@ | |
Copyright (C) 2012 by Tracelytics, Inc. | |
All rights reserved. | |
""" | |
-from oboe_ext import Context as SwigContext, Event as SwigEvent, UdpReporter, Metadata | |
- | |
import logging | |
import inspect | |
import random | |
@@ -17,6 +15,14 @@ from backport import defaultdict | |
from decorator import decorator | |
+try: | |
+ from oboe_ext import Context as SwigContext, Event as SwigEvent, UdpReporter, Metadata | |
+except ImportError, e: | |
+ from oboe_noop import Context as SwigContext, Event as SwigEvent, UdpReporter, Metadata | |
+ print >>sys.stderr, "Tracelytics Oboe warning: module not built on a platform with liboboe "\ | |
+ "and liboboe-dev installed, running in no-op mode. Tracing disabled. "\ | |
+ "Contact [email protected] if this is unexpected." | |
+ | |
__version__ = '1.3.0' | |
__all__ = ['config', 'Context', 'UdpReporter', 'Event'] | |
diff --git a/oboe/rum.py b/oboe/rum.py | |
index 570d074..7abc79e 100644 | |
--- a/oboe/rum.py | |
+++ b/oboe/rum.py | |
@@ -3,8 +3,13 @@ | |
Copyright (C) 2012 by Tracelytics, Inc. | |
All rights reserved. | |
""" | |
+import sys | |
+ | |
+try: | |
+ from oboe_ext import Context as SwigContext, Event as SwigEvent, UdpReporter, Metadata | |
+except ImportError, e: | |
+ from oboe_noop import Context as SwigContext, Event as SwigEvent, UdpReporter, Metadata | |
-from oboe_ext import Context as SwigContext | |
import hashlib, binascii, re, logging | |
_log = logging.getLogger('oboe') | |
diff --git a/setup.py b/setup.py | |
index 07105ca..4a5c457 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -4,13 +4,21 @@ | |
All rights reserved. | |
""" | |
+import os | |
from setuptools import setup, Extension | |
version = '1.3.0' | |
-oboe_module = Extension('oboe._oboe_ext', | |
- sources=['oboe/oboe_wrap.cxx'], | |
- depends=['oboe/oboe.hpp'], | |
- libraries=['oboe']) | |
+# conditionally build extensions if liboboe and liboboe-dev are available on this platform | |
+# otherwise, will function in no-op mode: no tracing, but all API endpoints available | |
+can_compile = True | |
+if can_compile: | |
+ oboe_module = Extension('oboe._oboe_ext', | |
+ sources=['oboe/oboe_wrap.cxx'], | |
+ depends=['oboe/oboe.hpp'], | |
+ libraries=['oboe']) | |
+ ext_modules = [oboe_module] | |
+else: | |
+ ext_modules = [] | |
setup(name = 'oboe', | |
version = version, | |
@@ -22,7 +30,7 @@ setup(name = 'oboe', | |
'for WSGI, Django, and Tornado.', | |
long_description = open('README.txt').read(), | |
keywords='tracelytics oboe liboboe instrumentation performance wsgi middleware django', | |
- ext_modules = [oboe_module], | |
+ ext_modules = ext_modules, | |
packages = ['oboe', 'oboeware'], | |
license = 'LICENSE.txt', | |
install_requires = ['decorator'], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment