~ubuntu-branches/ubuntu/jaunty/ecasound2.2/jaunty

« back to all changes in this revision

Viewing changes to pyecasound/pyeca.py

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2005-04-14 09:15:48 UTC
  • Revision ID: james.westby@ubuntu.com-20050414091548-o7kgb47z0tcunh0s
Tags: upstream-2.4.1
ImportĀ upstreamĀ versionĀ 2.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Wrapper module which loads pyecasound 
 
2
(python module for Ecasound Control Interface).
 
3
 
 
4
To use C version of pyecasound, you have to enable global share of symbols.
 
5
 
 
6
Quote from python docs:
 
7
 
 
8
--cut--
 
9
 
 
10
    setdlopenflags(n)
 
11
    
 
12
    Set the flags used by the interpreter for dlopen() calls, 
 
13
    such as when the interpreter loads extension modules. 
 
14
    Among other things, this will enable a lazy resolving of symbols 
 
15
    when importing a module, if called as sys.setdlopenflags(0). 
 
16
    To share symbols across extension modules, call as 
 
17
    sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL). 
 
18
    Symbolic names for the flag modules can be either found in the dl module, 
 
19
    or in the DLFCN module. If DLFCN is not available, 
 
20
    it can be generated from /usr/include/dlfcn.h using the h2py script. 
 
21
    Availability: Unix. New in version 2.2.
 
22
    
 
23
--cut--
 
24
    
 
25
 
 
26
Otherwise falling back to native python version (possibly slower float-handling).
 
27
"""
 
28
 
 
29
import sys
 
30
 
 
31
if hasattr(sys, 'version_info'): # attribute available from python 2.0
 
32
    if sys.version_info[1] >=2:
 
33
        try:
 
34
            import dl 
 
35
            sys.setdlopenflags(dl.RTLD_LAZY|dl.RTLD_GLOBAL)     
 
36
            
 
37
            from pyecasound import *
 
38
        except:
 
39
            pass
 
40
        
 
41
        try:
 
42
            import DLFCN
 
43
            sys.setdlopenflags(DLFCN.RTLD_LAZY|DLFCN.RTLD_GLOBAL)       
 
44
            
 
45
            from pyecasound import *
 
46
        except:
 
47
            from ecacontrol import *            
 
48
    else:
 
49
        from ecacontrol import *        
 
50
else:
 
51
    from ecacontrol import *
 
52