• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

simonsobs / so3g / 8837661016

25 Apr 2024 06:33PM UTC coverage: 49.186% (-0.08%) from 49.262%
8837661016

push

github

web-flow
Merge pull request #177 from simonsobs/spt3g-2024-04

Update bundled spt3g version to 0.3-276-gbe879ce

1299 of 2641 relevant lines covered (49.19%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.0
/python/load_pybindings.py
1
#
2
# Based on spt3g.core.load_bindings.
3
#
4
import platform, sys, os
1✔
5
try:
1✔
6
    # Starting in spt3g 0.3-240-ga9d32d5, a custom loader is available.
7
    from spt3g import dload
1✔
8
    imp = None
1✔
9
except ImportError:
×
10
    # The imp module is deprecated; to suppress warning, upgrade spt3g ^^^.
11
    import imp
×
12
    dload = None
×
13

14
if platform.system().startswith('freebsd') or platform.system().startswith('FreeBSD'):
1✔
15
    # C++ modules are extremely fragile when loaded with RTLD_LOCAL,
16
    # which is what Python uses on FreeBSD by default, and maybe other
17
    # systems. Convince it to use RTLD_GLOBAL.
18
    
19
    # See thread by Abrahams et al:
20
    # http://mail.python.org/pipermail/python-dev/2002-May/024074.html
21
    sys.setdlopenflags(0x102)
×
22

23
def load_pybindings(paths, name=None, lib_suffix=None):
1✔
24
    """
25
    Load all non-private items from the libraries in the list "paths".
26
    Provide the full path to each library, but without extension.  The
27
    .so or .dylib will be appended depending on the system
28
    architecture.  The namespace into which the items are imported
29
    will be determined from the first path, unless name= is explicitly
30
    provided.
31
    """
32
    if lib_suffix is None:
1✔
33
        if platform.system().startswith('Darwin'):
1✔
34
            # OSX compatibility requires .dylib suffix
35
            lib_suffix = ".dylib"
×
36
        else:
37
            lib_suffix = ".so"
1✔
38
    for path in paths:
1✔
39
        if name is None:
1✔
40
            name = os.path.split(path)[1]
×
41
        # Save copy of current module def
42
        mod = sys.modules[name]
1✔
43
        if dload is None:
1✔
44
            m = imp.load_dynamic(name, path + lib_suffix)
×
45
        else:
46
            m = dload.load_dynamic(name, name, path + lib_suffix)
1✔
47
        sys.modules[name] = mod # Don't override Python mod with C++
1✔
48

49
        for (k,v) in m.__dict__.items():
1✔
50
            if not k.startswith("_"):
1✔
51
                mod.__dict__[k] = v
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc