File: python-multiarch.patch

package info (click to toggle)
odb-api 0.18.1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,452 kB
  • sloc: cpp: 115,083; ansic: 86,859; f90: 30,318; sql: 12,508; sh: 9,939; yacc: 3,680; python: 2,432; lex: 1,593; perl: 1,116; fortran: 341; csh: 214; makefile: 111; lisp: 17
file content (60 lines) | stat: -rw-r--r-- 2,272 bytes parent folder | download
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
Description: Find the libOdb.so.0d library in the appropriate place on Debian
Author: Alastair McKinstry <mckinstry@debian.org>
Last-Updated: 2017-11-04
Forwarded: not-needed

Index: odb-api-0.18.0/odb_api/src/python/odb/odbql.py
===================================================================
--- odb-api-0.18.0.orig/odb_api/src/python/odb/odbql.py
+++ odb-api-0.18.0/odb_api/src/python/odb/odbql.py
@@ -58,8 +58,20 @@ def connect(file_name):
     """
     return Connection(file_name)
 
+def multiarch_path():
+    """ Return the multiarch path to check on Debian"""
+    import subprocess
+    (ecode, res) = subprocess.getstatusoutput('dpkg-architecture')
+    if ecode != 0:
+        raise Exception("Failed to execute dpkg-architecture: is this a Debian system?")
+    for line in res.split():
+        var, val = line.split('=')
+        if var == 'DEB_HOST_MULTIARCH':
+            return '/usr/lib/' + val
+    raise Exception("DEB_HOST_MULTIARCH not defined")
+    
 def lib_extension():
-    if 'linux' in platform: return '.so'
+    if 'linux' in platform: return '.so.0d'
     if 'darwin' in platform: return '.dylib'
     if 'win' in platform: return '.DLL'
     raise Exception("Don't know lib extension for platform " + platform)
@@ -67,19 +79,23 @@ def lib_extension():
 def __find_lib(paths, lib='libOdb', extension = lib_extension()):
     file_name = lib + extension
     for p in paths:
-        path = p.split(os.sep)[:-1]
+        path = p.split(os.sep)
+        pth = os.sep.join(path + [file_name])
+        try:
+            r = CDLL(pth)
+            return r
+        except OSError:
+            pass
         for i in range(len(path)):
-            pth = os.sep.join(path + ['..'] * i + ['lib', file_name])
+            pth = os.sep.join(path[:-1] + ['..'] * i + ['lib', file_name])
             try:
                 r = CDLL(pth)
-                #print '__find_libOdb: FOUND', pth
                 return r
             except OSError:
-                #print '__find_libOdb: not found: ', pth
                 pass
     raise Exception("Can't find " + file_name)
 
-libodb = __find_lib([__file__, '/tmp/build/bundle/debug/bin'])
+libodb = __find_lib([__file__, multiarch_path()])
 
 # odbql prototypes
 odbql_open = libodb.odbql_open