File: simple-loader.patch

package info (click to toggle)
python-nxs 4.4.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 888 kB
  • sloc: python: 2,752; makefile: 152; sh: 10
file content (65 lines) | stat: -rw-r--r-- 2,570 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Description: Find libnexus by name and in multi-arch paths
 CDLL already has a path search facility that looks in the standard
 paths and gets multi-arch paths correct; the path search code in nxs
 gets this wrong and so for unix at least, it's best to just rip it
 all out.
Author: Stuart Prescott <stuart@debian.org>
--- a/nxs/napi.py
+++ b/nxs/napi.py
@@ -272,50 +272,19 @@
     # this will get changed as part of the install process
     # it should correspond to --libdir specified to ./configure
     # NEXUSLIB takes precedence
+    file = 'libNeXus.so.1'
     if 'NEXUSLIB' in os.environ:
         file = os.environ['NEXUSLIB']
         if not os.path.isfile(file):
             raise OSError("File %s from environment variable NEXUSLIB does "
                           "exist" % file)
-        files = [file]
-    else:
-        files = []
-
-    # Default names and locations to look for the library are system dependent
-    filedir = os.path.dirname(__file__)
-    if sys.platform in ('win32','cygwin'):
-        # NEXUSDIR is set by the Windows installer for NeXus
-        if 'NEXUSDIR' in os.environ:
-            winnxdir = os.environ['NEXUSDIR']
-        else:
-            winnxdir =  'C:/Program Files/NeXus Data Format'
-
-        files += [filedir+"/libNeXus-0.dll",
-                  winnxdir + '/bin/libNeXus-0.dll',
-                  filedir+"/libNeXus.dll"]
-    else:
-        if sys.platform in ('darwin'):
-            lib = 'libNeXus.0.dylib'
-            ldenv = 'DYLD_LIBRARY_PATH'
-        else:
-            lib = 'libNeXus.so.1'
-            ldenv = 'LD_LIBRARY_PATH'
-        # Search the load library path as well as the standard locations
-        ldpath = [p for p in os.environ.get(ldenv,'').split(':') if p != '']
-        stdpath = [ '/usr/local/lib', '/usr/local/lib64',
-                    '/usr/lib', '/usr/lib64']
-        files += [os.path.join(p,lib) for p in [filedir]+ldpath+stdpath]
 
     # Given a list of files, try loading the first one that is available.
-    for file in files:
-        if not os.path.isfile(file): continue
-        try:
-            return ctypes.cdll[file]
-        except:
-            raise OSError("NeXus library %s could not be loaded: %s" %
-                          (file,sys.exc_info()))
-    raise OSError("Set NEXUSLIB or move NeXus to one of: %s" %
-                  ", ".join(files))
+    try:
+        return ctypes.cdll[file]
+    except OSError:
+        pass
+    raise OSError("Set NEXUSLIB or put it in a standard location.")
 
 def _init():
     lib = _libnexus()