VirtualBox

source: vbox/trunk/src/VBox/Installer/common/vboxapisetup.py@ 59865

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

re-applied the Python 3 changes which were backed out in r105674 sans the changes in .cpp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1"""
2Copyright (C) 2009-2016 Oracle Corporation
3
4This file is part of VirtualBox Open Source Edition (OSE), as
5available from http://www.virtualbox.org. This file is free software;
6you can redistribute it and/or modify it under the terms of the GNU
7General Public License (GPL) as published by the Free Software
8Foundation, in version 2 as it comes in the "COPYING" file of the
9VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11"""
12
13import os,sys
14from distutils.core import setup
15
16def 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
25def 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
47def main(argv):
48 vboxDest = os.environ.get("VBOX_MSI_INSTALL_PATH", None)
49 if vboxDest is None:
50 vboxDest = os.environ.get('VBOX_INSTALL_PATH', None)
51 if vboxDest is None:
52 raise Exception("No VBOX_INSTALL_PATH defined, exiting")
53
54 vboxVersion = os.environ.get("VBOX_VERSION", None)
55 if vboxVersion is None:
56 # Should we use VBox version for binding module versioning?
57 vboxVersion = "1.0"
58
59 import platform
60
61 if platform.system() == 'Windows':
62 cleanupComCache()
63
64 # Darwin: Patched before installation. Modifying bundle is not allowed, breaks signing and upsets gatekeeper.
65 if platform.system() != 'Darwin':
66 vboxSdkDest = os.path.join(vboxDest, "sdk")
67 patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
68
69 setup(name='vboxapi',
70 version=vboxVersion,
71 description='Python interface to VirtualBox',
72 author='Oracle Corp.',
73 author_email='[email protected]',
74 url='http://www.virtualbox.org',
75 packages=['vboxapi']
76 )
77
78if __name__ == '__main__':
79 main(sys.argv)
80
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