VirtualBox

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

Last change on this file since 99856 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1"""
2Copyright (C) 2009-2023 Oracle and/or its affiliates.
3
4This file is part of VirtualBox base platform packages, as
5available from https://www.virtualbox.org.
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation, in version 3 of the
10License.
11
12This program is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, see <https://www.gnu.org/licenses>.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
23in the VirtualBox distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28
29SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
30"""
31
32import os,sys
33from distutils.core import setup
34
35def cleanupComCache():
36 import shutil
37 from distutils.sysconfig import get_python_lib
38 comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py')
39 comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py')
40 print("Cleaning COM cache at",comCache1,"and",comCache2)
41 shutil.rmtree(comCache1, True)
42 shutil.rmtree(comCache2, True)
43
44def patchWith(file,install,sdk):
45 newFile=file + ".new"
46 install=install.replace("\\", "\\\\")
47 try:
48 os.remove(newFile)
49 except:
50 pass
51 oldF = open(file, 'r')
52 newF = open(newFile, 'w')
53 for line in oldF:
54 line = line.replace("%VBOX_INSTALL_PATH%", install)
55 line = line.replace("%VBOX_SDK_PATH%", sdk)
56 newF.write(line)
57 newF.close()
58 oldF.close()
59 try:
60 os.remove(file)
61 except:
62 pass
63 os.rename(newFile, file)
64
65# See http://docs.python.org/distutils/index.html
66def main(argv):
67 vboxDest = os.environ.get("VBOX_MSI_INSTALL_PATH", None)
68 if vboxDest is None:
69 vboxDest = os.environ.get('VBOX_INSTALL_PATH', None)
70 if vboxDest is None:
71 raise Exception("No VBOX_INSTALL_PATH defined, exiting")
72
73 vboxVersion = os.environ.get("VBOX_VERSION", None)
74 if vboxVersion is None:
75 # Should we use VBox version for binding module versioning?
76 vboxVersion = "1.0"
77
78 import platform
79
80 if platform.system() == 'Windows':
81 cleanupComCache()
82
83 # Darwin: Patched before installation. Modifying bundle is not allowed, breaks signing and upsets gatekeeper.
84 if platform.system() != 'Darwin':
85 vboxSdkDest = os.path.join(vboxDest, "sdk")
86 patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
87
88 setup(name='vboxapi',
89 version=vboxVersion,
90 description='Python interface to VirtualBox',
91 author='Oracle Corp.',
92 author_email='[email protected]',
93 url='http://www.virtualbox.org',
94 packages=['vboxapi']
95 )
96
97if __name__ == '__main__':
98 main(sys.argv)
99
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