VirtualBox

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

Last change on this file since 33432 was 33432, checked in by vboxsync, 15 years ago

Python: cleanup COM cache in installer

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