From 20469390bd0ce6fce22a8ad67296317121bc3dae Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 27 May 2006 12:18:54 +0000 Subject: [PATCH] gst/__init__.py: Make gst-python work on OS without dl.so Original commit message from CVS: reviewed by: Edward Hervey * gst/__init__.py: Make gst-python work on OS without dl.so Fixes #341799 --- ChangeLog | 8 ++++++++ gst/__init__.py | 28 +++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 916e7651f6..665c683a7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-05-27 Yuri Pankov + + reviewed by: Edward Hervey + + * gst/__init__.py: + Make gst-python work on OS without dl.so + Fixes #341799 + 2006-04-27 Johan Rydberg reviewed by: Edward Hervey diff --git a/gst/__init__.py b/gst/__init__.py index 394ea1a412..a6104a3317 100644 --- a/gst/__init__.py +++ b/gst/__init__.py @@ -83,17 +83,35 @@ class Fraction(Value): def __repr__(self): return '' % (self.num, self.denom) -import DLFCN, sys +import sys dlsave = sys.getdlopenflags() -sys.setdlopenflags(DLFCN.RTLD_LAZY | DLFCN.RTLD_GLOBAL) +try: + from DLFCN import RTLD_GLOBAL, RTLD_LAZY +except ImportError: + RTLD_GLOBAL = -1 + RTLD_LAZY = -1 + import os + osname = os.uname()[0] + if osname == 'Linux' or osname == 'SunOS' or osname == 'FreeBSD': + RTLD_GLOBAL = 0x100 + RTLD_LAZY = 0x1 + elif osname == 'Darwin': + RTLD_GLOBAL = 0x8 + RTLD_LAZY = 0x1 + del os +except: + RTLD_GLOBAL = -1 + RTLD_LAZY = -1 -from _gst import * -import interfaces +if RTLD_GLOBAL != -1 and RTLD_LAZY != -1: + sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL) + from _gst import * + import interfaces version = get_gst_version sys.setdlopenflags(dlsave) -del DLFCN, sys +del sys # this restores previously installed importhooks, so we don't interfere # with other people's module importers