VirtualBox

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

Last change on this file since 78126 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1"""
2Copyright (C) 2009-2019 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
12The contents of this file may alternatively be used under the terms
13of the Common Development and Distribution License Version 1.0
14(CDDL) only, as it comes in the "COPYING.CDDL" file of the
15VirtualBox OSE distribution, in which case the provisions of the
16CDDL are applicable instead of those of the GPL.
17
18You may elect to license modified versions of this file under the
19terms and conditions of either the GPL or the CDDL or both.
20"""
21
22import os,sys
23from distutils.core import setup
24
25def cleanupComCache():
26 import shutil
27 from distutils.sysconfig import get_python_lib
28 comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py')
29 comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py')
30 print("Cleaning COM cache at",comCache1,"and",comCache2)
31 shutil.rmtree(comCache1, True)
32 shutil.rmtree(comCache2, True)
33
34def patchWith(file,install,sdk):
35 newFile=file + ".new"
36 install=install.replace("\\", "\\\\")
37 try:
38 os.remove(newFile)
39 except:
40 pass
41 oldF = open(file, 'r')
42 newF = open(newFile, 'w')
43 for line in oldF:
44 line = line.replace("%VBOX_INSTALL_PATH%", install)
45 line = line.replace("%VBOX_SDK_PATH%", sdk)
46 newF.write(line)
47 newF.close()
48 oldF.close()
49 try:
50 os.remove(file)
51 except:
52 pass
53 os.rename(newFile, file)
54
55# See http://docs.python.org/distutils/index.html
56def main(argv):
57 vboxDest = os.environ.get("VBOX_MSI_INSTALL_PATH", None)
58 if vboxDest is None:
59 vboxDest = os.environ.get('VBOX_INSTALL_PATH', None)
60 if vboxDest is None:
61 raise Exception("No VBOX_INSTALL_PATH defined, exiting")
62
63 vboxVersion = os.environ.get("VBOX_VERSION", None)
64 if vboxVersion is None:
65 # Should we use VBox version for binding module versioning?
66 vboxVersion = "1.0"
67
68 import platform
69
70 if platform.system() == 'Windows':
71 cleanupComCache()
72
73 # Darwin: Patched before installation. Modifying bundle is not allowed, breaks signing and upsets gatekeeper.
74 if platform.system() != 'Darwin':
75 vboxSdkDest = os.path.join(vboxDest, "sdk")
76 patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
77
78 setup(name='vboxapi',
79 version=vboxVersion,
80 description='Python interface to VirtualBox',
81 author='Oracle Corp.',
82 author_email='vbox-dev@virtualbox.org',
83 url='http://www.virtualbox.org',
84 packages=['vboxapi']
85 )
86
87if __name__ == '__main__':
88 main(sys.argv)
89
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