VirtualBox

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

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

re-applied the remaining changes which were backed out in r105674

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 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 else:
40 lib64 = None
41 return [os.path.join(p, "include", "python"+v), lib, lib64]
42
43def print_vars(vers, known, sep, bitness_magic):
44 print("VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep))
45 if bitness_magic > 0:
46 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep))
47 print("VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep))
48 else:
49 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep))
50
51
52def main(argv):
53 global prefixes
54 global versions
55
56 dllpre = "lib"
57 dllsuff = ".so"
58 bitness_magic = 0
59
60 if len(argv) > 1:
61 target = argv[1]
62 else:
63 target = sys.platform
64
65 if len(argv) > 2:
66 arch = argv[2]
67 else:
68 arch = "unknown"
69
70 if len(argv) > 3:
71 multi = int(argv[3])
72 else:
73 multi = 1
74
75 if multi == 0:
76 prefixes = ["/usr"]
77 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1])]
78
79 if target == 'darwin':
80 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
81 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr',
82 '/Developer/SDKs/MacOSX10.5.sdk/usr',
83 '/Developer/SDKs/MacOSX10.6.sdk/usr',
84 '/Developer/SDKs/MacOSX10.7.sdk/usr']
85 dllsuff = '.dylib'
86
87 if target == 'solaris' and arch == 'amd64':
88 bitness_magic = 1
89
90 if target == 'linux' and arch == 'amd64':
91 bitness_magic = 2
92
93 for v in versions:
94 if StrictVersion(v) < StrictVersion('2.6'):
95 continue
96 for p in prefixes:
97 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
98 if c is not None:
99 known[v] = c
100 break
101 keys = list(known.keys())
102 # we want default to be the lowest versioned Python
103 keys.sort()
104 d = None
105 # We need separator other than newline, to sneak through $(shell)
106 sep = "|"
107 for k in keys:
108 if d is None:
109 d = k
110 vers = k.replace('.', '')
111 print_vars(vers, known[k], sep, bitness_magic)
112 if d is not None:
113 print_vars("DEF", known[d], sep, bitness_magic)
114
115if __name__ == '__main__':
116 main(sys.argv)
Note: See TracBrowser for help on using the repository browser.

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