File: __init__.py

package info (click to toggle)
python-lupa 1.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,876 kB
  • sloc: python: 2,332; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from __future__ import absolute_import


# We need to enable global symbol visibility for lupa in order to
# support binary module loading in Lua.  If we can enable it here, we
# do it temporarily.

def _try_import_with_global_library_symbols():
    try:
        from os import RTLD_NOW, RTLD_GLOBAL
    except ImportError:
        from DLFCN import RTLD_NOW, RTLD_GLOBAL  # Py2.7
    dlopen_flags = RTLD_NOW | RTLD_GLOBAL

    import sys
    old_flags = sys.getdlopenflags()
    try:
        sys.setdlopenflags(dlopen_flags)
        import lupa._lupa
    finally:
        sys.setdlopenflags(old_flags)

try:
    _try_import_with_global_library_symbols()
except:
    pass

del _try_import_with_global_library_symbols

# the following is all that should stay in the namespace:

from lupa._lupa import *

try:
    from lupa.version import __version__
except ImportError:
    pass