VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/gen_python_deps.py@ 59836

Last change on this file since 59836 was 59836, checked in by vboxsync, 9 years ago

xpcom/gen_python_deps.py: ignore non-existent libraries. On Debian/Ubuntu there is no /usr/lib/x86_64-linux-gnu/libpython3.5.so but there is only /usr/lib/x86_64-linux-gnu/libpython3.5m.so

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1#!/usr/bin/python
2
3"""
4Copyright (C) 2009-2016 Oracle Corporation
5
6This file is part of VirtualBox Open Source Edition (OSE), as
7available from http://www.virtualbox.org. This file is free software;
8you can redistribute it and/or modify it under the terms of the GNU
9General Public License (GPL) as published by the Free Software
10Foundation, in version 2 as it comes in the "COPYING" file of the
11VirtualBox OSE distribution. VirtualBox OSE is distributed in the
12hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13"""
14
15import os,sys
16from distutils.version import StrictVersion
17
18versions = ["2.6", "2.7", "3.1", "3.2", "3.3", "3.4", "3.5"]
19prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
20known = {}
21
22def checkPair(p, v,dllpre,dllsuff, bitness_magic):
23 file = os.path.join(p, "include", "python"+v, "Python.h")
24 if not os.path.isfile(file):
25 return None
26
27 lib = os.path.join(p, "lib/i386-linux-gnu", dllpre+"python"+v+dllsuff)
28 if not os.path.isfile(lib):
29 lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
30
31 if bitness_magic == 1:
32 lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
33 elif bitness_magic == 2:
34 lib64 = os.path.join(p, "lib/x86_64-linux-gnu", dllpre+"python"+v+dllsuff)
35 if not os.path.isfile(lib64):
36 lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
37 if not os.path.isfile(lib64):
38 lib64 = lib
39 if not os.path.isfile(lib64):
40 return None
41
42 else:
43 lib64 = None
44 return [os.path.join(p, "include", "python"+v), lib, lib64]
45
46def print_vars(vers, known, sep, bitness_magic):
47 print("VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep))
48 if bitness_magic > 0:
49 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep))
50 print("VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep))
51 else:
52 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep))
53
54
55def main(argv):
56 global prefixes
57 global versions
58
59 dllpre = "lib"
60 dllsuff = ".so"
61 bitness_magic = 0
62
63 if len(argv) > 1:
64 target = argv[1]
65 else:
66 target = sys.platform
67
68 if len(argv) > 2:
69 arch = argv[2]
70 else:
71 arch = "unknown"
72
73 if len(argv) > 3:
74 multi = int(argv[3])
75 else:
76 multi = 1
77
78 if multi == 0:
79 prefixes = ["/usr"]
80 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
81
82 if target == 'darwin':
83 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
84 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr',
85 '/Developer/SDKs/MacOSX10.5.sdk/usr',
86 '/Developer/SDKs/MacOSX10.6.sdk/usr',
87 '/Developer/SDKs/MacOSX10.7.sdk/usr']
88 dllsuff = '.dylib'
89
90 if target == 'solaris' and arch == 'amd64':
91 bitness_magic = 1
92
93 if target == 'linux' and arch == 'amd64':
94 bitness_magic = 2
95
96 for v in versions:
97 if StrictVersion(v) < StrictVersion('2.6'):
98 continue
99 for p in prefixes:
100 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
101 if c is not None:
102 known[v] = c
103 break
104 keys = list(known.keys())
105 # we want default to be the lowest versioned Python
106 keys.sort()
107 d = None
108 # We need separator other than newline, to sneak through $(shell)
109 sep = "|"
110 for k in keys:
111 if d is None:
112 d = k
113 vers = k.replace('.', '')
114 print_vars(vers, known[k], sep, bitness_magic)
115 if d is not None:
116 print_vars("DEF", known[d], sep, bitness_magic)
117
118if __name__ == '__main__':
119 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette