1 | """
|
---|
2 | Copyright (C) 2009-2015 Oracle Corporation
|
---|
3 |
|
---|
4 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | available from http://www.virtualbox.org. This file is free software;
|
---|
6 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | General Public License (GPL) as published by the Free Software
|
---|
8 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | """
|
---|
12 |
|
---|
13 | import os,sys
|
---|
14 | from distutils.core import setup
|
---|
15 |
|
---|
16 | def cleanupComCache():
|
---|
17 | import shutil
|
---|
18 | from distutils.sysconfig import get_python_lib
|
---|
19 | comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py')
|
---|
20 | comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py')
|
---|
21 | print "Cleaning COM cache at",comCache1,"and",comCache2
|
---|
22 | shutil.rmtree(comCache1, True)
|
---|
23 | shutil.rmtree(comCache2, True)
|
---|
24 |
|
---|
25 | def patchWith(file,install,sdk):
|
---|
26 | newFile=file + ".new"
|
---|
27 | install=install.replace("\\", "\\\\")
|
---|
28 | try:
|
---|
29 | os.remove(newFile)
|
---|
30 | except:
|
---|
31 | pass
|
---|
32 | oldF = open(file, 'r')
|
---|
33 | newF = open(newFile, 'w')
|
---|
34 | for line in oldF:
|
---|
35 | line = line.replace("%VBOX_INSTALL_PATH%", install)
|
---|
36 | line = line.replace("%VBOX_SDK_PATH%", sdk)
|
---|
37 | newF.write(line)
|
---|
38 | newF.close()
|
---|
39 | oldF.close()
|
---|
40 | try:
|
---|
41 | os.remove(file)
|
---|
42 | except:
|
---|
43 | pass
|
---|
44 | os.rename(newFile, file)
|
---|
45 |
|
---|
46 | # See http://docs.python.org/distutils/index.html
|
---|
47 | def main(argv):
|
---|
48 | vboxDest = os.environ.get("VBOX_INSTALL_PATH", None)
|
---|
49 | if vboxDest is None:
|
---|
50 | raise Exception("No VBOX_INSTALL_PATH defined, exiting")
|
---|
51 |
|
---|
52 | vboxVersion = os.environ.get("VBOX_VERSION", None)
|
---|
53 | if vboxVersion is None:
|
---|
54 | # Should we use VBox version for binding module versioning?
|
---|
55 | vboxVersion = "1.0"
|
---|
56 |
|
---|
57 | import platform
|
---|
58 |
|
---|
59 | if platform.system() == 'Windows':
|
---|
60 | cleanupComCache()
|
---|
61 |
|
---|
62 | # Darwin: Patched before installation. Modifying bundle is not allowed, breaks signing and upsets gatekeeper.
|
---|
63 | if platform.system() != 'Darwin':
|
---|
64 | vboxSdkDest = os.path.join(vboxDest, "sdk")
|
---|
65 | patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
|
---|
66 |
|
---|
67 | setup(name='vboxapi',
|
---|
68 | version=vboxVersion,
|
---|
69 | description='Python interface to VirtualBox',
|
---|
70 | author='Oracle Corp.',
|
---|
71 | author_email='[email protected]',
|
---|
72 | url='http://www.virtualbox.org',
|
---|
73 | packages=['vboxapi']
|
---|
74 | )
|
---|
75 |
|
---|
76 | if __name__ == '__main__':
|
---|
77 | main(sys.argv)
|
---|
78 |
|
---|