VirtualBox

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

Last change on this file since 78387 was 77811, checked in by vboxsync, 6 years ago

accidentally made commit was reverted.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 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
15from __future__ import print_function
16import os,sys
17from distutils.version import StrictVersion
18
19versions = ["2.6", "2.7", "3.1", "3.2", "3.2m", "3.3", "3.3m", "3.4", "3.4m", "3.5", "3.5m", "3.6", "3.6m", "3.7", "3.7m"]
20prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
21known = {}
22
23def checkPair(p, v, dllpre, dllsuff, bitness_magic):
24 incdir = os.path.join(p, "include", "python"+v)
25 incfile = os.path.join(incdir, "Python.h")
26 if not os.path.isfile(incfile):
27 return None
28
29 lib = os.path.join(p, "lib/i386-linux-gnu", dllpre+"python"+v+dllsuff)
30 if not os.path.isfile(lib):
31 lib = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
32 if not os.path.isfile(lib):
33 lib = None
34
35 if bitness_magic == 1:
36 lib64 = os.path.join(p, "lib", "64", dllpre+"python"+v+dllsuff)
37 if not os.path.isfile(lib64):
38 lib64 = None
39 elif bitness_magic == 2:
40 lib64 = os.path.join(p, "lib/x86_64-linux-gnu", dllpre+"python"+v+dllsuff)
41 if not os.path.isfile(lib64):
42 lib64 = os.path.join(p, "lib64", dllpre+"python"+v+dllsuff)
43 if not os.path.isfile(lib64):
44 lib64 = os.path.join(p, "lib", dllpre+"python"+v+dllsuff)
45 if not os.path.isfile(lib64):
46 lib64 = None
47 else:
48 lib64 = None
49
50 if lib is None and lib64 is None:
51 return None
52 else:
53 return [incdir, lib, lib64]
54
55def print_vars(vers, known, sep, bitness_magic):
56 print("VBOX_PYTHON%s_INC=%s%s" %(vers, known[0], sep))
57 if bitness_magic > 0:
58 if known[2]:
59 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep))
60 if known[1]:
61 print("VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep))
62 else:
63 print("VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep))
64
65
66def main(argv):
67 global prefixes
68 global versions
69
70 dllpre = "lib"
71 dllsuff = ".so"
72 bitness_magic = 0
73
74 if len(argv) > 1:
75 target = argv[1]
76 else:
77 target = sys.platform
78
79 if len(argv) > 2:
80 arch = argv[2]
81 else:
82 arch = "unknown"
83
84 if len(argv) > 3:
85 multi = int(argv[3])
86 else:
87 multi = 1
88
89 if multi == 0:
90 prefixes = ["/usr"]
91 versions = [str(sys.version_info[0])+'.'+str(sys.version_info[1]),
92 str(sys.version_info[0])+'.'+str(sys.version_info[1])+'m']
93
94 if target == 'darwin':
95 ## @todo Pick up the locations from VBOX_PATH_MACOSX_SDK_10_*.
96 prefixes = ['/Developer/SDKs/MacOSX10.4u.sdk/usr',
97 '/Developer/SDKs/MacOSX10.5.sdk/usr',
98 '/Developer/SDKs/MacOSX10.6.sdk/usr',
99 '/Developer/SDKs/MacOSX10.7.sdk/usr']
100 dllsuff = '.dylib'
101
102 if target == 'solaris' and arch == 'amd64':
103 bitness_magic = 1
104
105 if target == 'linux' and arch == 'amd64':
106 bitness_magic = 2
107
108 for v in versions:
109 if v.endswith("m"):
110 realversion = v[:-1]
111 else:
112 realversion = v
113 if StrictVersion(realversion) < StrictVersion('2.6'):
114 continue
115 for p in prefixes:
116 c = checkPair(p, v, dllpre, dllsuff, bitness_magic)
117 if c is not None:
118 known[v] = c
119 break
120 keys = list(known.keys())
121 # we want default to be the lowest versioned Python
122 keys.sort()
123 d = None
124 # We need separator other than newline, to sneak through $(shell)
125 sep = "|"
126 for k in keys:
127 if d is None:
128 d = k
129 vers = k.replace('.', '').upper()
130 print_vars(vers, known[k], sep, bitness_magic)
131 if d is not None:
132 print_vars("DEF", known[d], sep, bitness_magic)
133 else:
134 print(argv[0] + ": No Python development package found!", file=sys.stderr)
135
136if __name__ == '__main__':
137 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