1 | """
|
---|
2 | Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
3 |
|
---|
4 | This file is part of VirtualBox base platform packages, as
|
---|
5 | available from https://www.virtualbox.org.
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or
|
---|
8 | modify it under the terms of the GNU General Public License
|
---|
9 | as published by the Free Software Foundation, in version 3 of the
|
---|
10 | License.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful, but
|
---|
13 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
23 | in the VirtualBox distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 |
|
---|
29 | SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
30 | """
|
---|
31 |
|
---|
32 | import os,sys
|
---|
33 | from distutils.core import setup
|
---|
34 |
|
---|
35 | def 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 |
|
---|
44 | def 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
|
---|
66 | def 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 |
|
---|
97 | if __name__ == '__main__':
|
---|
98 | main(sys.argv)
|
---|
99 |
|
---|