This repository has been archived by the owner on Apr 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.py
290 lines (258 loc) · 14.3 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/usr/bin/env python
# vim: expandtab ts=4 sw=4 sts=4 fileencoding=utf-8:
"""Setup script for the GNS3 packages."""
import sys, os, shutil, platform
sys.path.append('./src')
from distutils.core import setup, Extension
from glob import glob
# current version of GNS3
VERSION = "0.8.7"
try:
# delete previous build
if os.access('./build', os.F_OK):
shutil.rmtree('./build')
if os.access('./dist', os.F_OK):
shutil.rmtree('./dist')
except:
pass
if sys.platform.startswith('win'):
import struct
bitness = struct.calcsize("P") * 8
# Set the path to Qt plugins directory
if bitness == 32:
# for 32-bit python
PYQT4_DIR = r'C:\Python27-32bit\Lib\site-packages\PyQt4'
elif bitness == 64:
# for 64-bit python
PYQT4_DIR = r'C:\Python27-64bit\Lib\site-packages\PyQt4'
else:
# should seriously not happen ...
print "Fatal error: bitness cannot be detected!"
sys.exit(1)
try:
import py2exe
except ImportError:
raise RuntimeError, "Cannot import py2exe"
data_files = [("Langs", glob(r'src\GNS3\Langs\*.qm')),
('src\GNS3\Dynagen\configspec'),
('COPYING'),
('baseconfig.txt'),
('baseconfig_sw.txt'),
(PYQT4_DIR + r'\QtXml4.dll'),
("iconengines", glob(PYQT4_DIR + r'\plugins\iconengines\*.dll')),
("imageformats", glob(PYQT4_DIR + r'\plugins\imageformats\*.dll'))]
# Settings for py2exe, packages values are to tell to py2exe about hidden imports
setup(windows=[{"script":"gns3.pyw",
"icon_resources": [(1, r'..\gns3_icon.ico')]}],
zipfile=None,
data_files=data_files,
options={"py2exe":
{
"includes": ["sip"],
"dll_excludes": ["MSVCP90.dll", "POWRPROF.dll", "MSWSOCK.dll"],
"optimize": 1,
# CLSID for VirtualBox COM (http://www.py2exe.org/index.cgi/IncludingTypelibs)
# Do not need this anymore because the typelib wrapper is dynamically generated.
#"typelibs": [('{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}',0,1,3)], #
"packages": ["GNS3.Ui.ConfigurationPages.Page_ATMSW",
"GNS3.Ui.ConfigurationPages.Page_ATMBR",
"GNS3.Ui.ConfigurationPages.Page_Cloud",
"GNS3.Ui.ConfigurationPages.Page_ETHSW",
"GNS3.Ui.ConfigurationPages.Page_Hub",
"GNS3.Ui.ConfigurationPages.Page_FRSW",
"GNS3.Ui.ConfigurationPages.Page_IOSRouter",
"GNS3.Ui.ConfigurationPages.Page_PIX",
"GNS3.Ui.ConfigurationPages.Page_ASA",
"GNS3.Ui.ConfigurationPages.Page_AWP",
"GNS3.Ui.ConfigurationPages.Page_JunOS",
"GNS3.Ui.ConfigurationPages.Page_IDS",
"GNS3.Ui.ConfigurationPages.Page_Qemu",
"GNS3.Ui.ConfigurationPages.Page_VirtualBox",
"GNS3.Ui.ConfigurationPages.Page_DecorativeNode",
"GNS3.Ui.ConfigurationPages.Page_PreferencesDynamips",
"GNS3.Ui.ConfigurationPages.Page_PreferencesGeneral",
"GNS3.Ui.ConfigurationPages.Page_PreferencesCapture",
"GNS3.Ui.ConfigurationPages.Page_PreferencesQemu",
"GNS3.Ui.ConfigurationPages.Page_PreferencesVirtualBox",
"GNS3.Ui.ConfigurationPages.Page_PreferencesDeployementWizard",
]
}
}
)
# Compile qemuwrapper
sys.path.append('./qemuwrapper')
setup(console=['qemuwrapper/qemuwrapper.py'], options = {"py2exe": {"dll_excludes": ["POWRPROF.dll", "MSWSOCK.dll"]}}, zipfile=None)
# Compile vboxwrapper
sys.path.append('./vboxwrapper')
setup(console=['vboxwrapper/vboxwrapper.py'], options = {"py2exe": {"dll_excludes": ["POWRPROF.dll", "MSWSOCK.dll"]}}, zipfile=None)
elif sys.platform.startswith('darwin'):
import setuptools
QTDIR = r'/Developer/Applications/Qt'
data_files = [('', glob(r'src/GNS3/Langs/*.qm')),
('src/GNS3/Dynagen/configspec'),
('qemuwrapper/qemuwrapper.py'),
# ('vboxwrapper/vboxwrapper.py'),
# ('vboxwrapper/vboxcontroller_4_1.py'),
# ('vboxwrapper/tcp_pipe_proxy.py'),
('baseconfig.txt'),
('baseconfig_sw.txt'),
('COPYING'),
("../PlugIns/iconengines", [QTDIR + r'/plugins/iconengines/libqsvgicon.dylib']),
("../PlugIns/imageformats", [QTDIR + r'/plugins/imageformats/libqgif.dylib',
QTDIR + r'/plugins/imageformats/libqjpeg.dylib',
QTDIR + r'/plugins/imageformats/libqsvg.dylib'])
]
APP = ['gns3.pyw']
OPTIONS = {'argv_emulation': False,
'semi_standalone': True,
'site_packages': True,
'optimize': 1,
'iconfile': 'gns3.icns',
'includes': ['sip',
'PyQt4.QtCore',
'PyQt4.QtGui',
'PyQt4.QtSvg',
'PyQt4.QtXml',
'PyQt4.QtNetwork',
'PyQt4.QtWebKit',
'GNS3.Ui.ConfigurationPages.Page_ATMSW',
'GNS3.Ui.ConfigurationPages.Page_ATMBR',
'GNS3.Ui.ConfigurationPages.Page_Cloud',
'GNS3.Ui.ConfigurationPages.Page_ETHSW',
'GNS3.Ui.ConfigurationPages.Page_Hub',
'GNS3.Ui.ConfigurationPages.Page_FRSW',
'GNS3.Ui.ConfigurationPages.Page_IOSRouter',
'GNS3.Ui.ConfigurationPages.Page_PIX',
'GNS3.Ui.ConfigurationPages.Page_ASA',
'GNS3.Ui.ConfigurationPages.Page_AWP',
'GNS3.Ui.ConfigurationPages.Page_JunOS',
'GNS3.Ui.ConfigurationPages.Page_IDS',
'GNS3.Ui.ConfigurationPages.Page_Qemu',
'GNS3.Ui.ConfigurationPages.Page_VirtualBox',
'GNS3.Ui.ConfigurationPages.Page_DecorativeNode',
'GNS3.Ui.ConfigurationPages.Page_PreferencesDynamips',
'GNS3.Ui.ConfigurationPages.Page_PreferencesGeneral',
'GNS3.Ui.ConfigurationPages.Page_PreferencesCapture',
'GNS3.Ui.ConfigurationPages.Page_PreferencesQemu',
'GNS3.Ui.ConfigurationPages.Page_PreferencesVirtualBox',
'GNS3.Ui.ConfigurationPages.Page_PreferencesDeployementWizard',
],
'plist' : { 'CFBundleName': 'GNS3',
'CFBundleDisplayName': 'GNS3',
'CFBundleGetInfoString' : 'GNS3, Graphical Network Simulator',
'CFBundleIdentifier':'net.gns3',
'CFBundleShortVersionString':VERSION,
'CFBundleVersion': 'GNS3 ' + VERSION,
'LSMinimumSystemVersion':'10.5',
'LSMultipleInstancesProhibited':'true',
'NSHumanReadableCopyright':'GNU General Public License (GPL), Jeremy Grossmann',
'CFBundleDocumentTypes': [{
'CFBundleTypeExtensions': ['net'],
'CFBundleTypeName': 'GNS3 Topology',
'CFBundleTypeRole': 'Editor',
'CFBundleTypeIconFile': 'gns3.icns',
}]
}
}
setuptools.setup(
name='GNS3',
app=APP,
data_files=data_files,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
print '*** Removing Qt debug libs ***'
for root, dirs, files in os.walk('./dist'):
for file in files:
if 'debug' in file:
print 'Deleting', file
os.remove(os.path.join(root,file))
os.chdir('dist')
print '*** Patching __boot__.py ***'
# This adds sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.x', 'lib-dynload')] + sys.path
# to dist/GNS3.app/Contents/Resources/__boot__.py
os.system('cp ../__boot__.py ./GNS3.app/Contents/Resources')
print '*** Installing qt.conf ***'
os.system('cp ../qt.conf ./GNS3.app/Contents/Resources')
print '*** Installing Dynamips ***'
os.system('cp ../dynamips-0.2.8-RC3-community-OSX.intel64.bin ./GNS3.app/Contents/Resources')
os.system('cp ../dynamips ./GNS3.app/Contents/Resources')
print '*** Installing Qemu 0.11.0 ***'
os.system('mkdir -p ./GNS3.app/Contents/Resources/Qemu-0.11.0')
os.system('cp -R ../Qemu-0.11.0/* ./GNS3.app/Contents/Resources/Qemu-0.11.0')
print '*** Installing Qemu 0.14.1 ***'
os.system('mkdir -p ./GNS3.app/Contents/Resources/Qemu-0.14.1')
os.system('cp -R ../Qemu-0.14.1/* ./GNS3.app/Contents/Resources/Qemu-0.14.1')
print '*** Installing VPCS ***'
os.system('cp ../vpcs ./GNS3.app/Contents/Resources')
print '*** Applying permissions ***'
#os.chmod('./GNS3.app/Contents/Resources/vboxwrapper.py', 0755)
os.chmod('./GNS3.app/Contents/Resources/qemuwrapper.py', 0755)
os.chmod('./GNS3.app/Contents/Resources/Qemu-0.11.0/bin/qemu', 0755)
os.chmod('./GNS3.app/Contents/Resources/Qemu-0.11.0/bin/qemu-img', 0755)
os.chmod('./GNS3.app/Contents/Resources/Qemu-0.14.1/bin/qemu-system-i386', 0755)
os.chmod('./GNS3.app/Contents/Resources/Qemu-0.14.1/bin/qemu-system-x86_64', 0755)
os.chmod('./GNS3.app/Contents/Resources/Qemu-0.14.1/bin/qemu-img', 0755)
os.chmod('./GNS3.app/Contents/Resources/dynamips-0.2.8-RC3-community-OSX.intel64.bin', 0755)
os.chmod('./GNS3.app/Contents/Resources/dynamips', 0755)
os.chmod('./GNS3.app/Contents/Resources/vpcs', 0755)
print '*** Compiling & installing VBoxWrapper ***'
setuptools.setup(name='VBoxWrapper', app=['../vboxwrapper/vboxwrapper.py'], options={'py2app': {'semi_standalone': True, 'site_packages': True, 'optimize': 1}}, setup_requires=['py2app'])
os.system('cp -R ./dist/VBoxWrapper.app/ ./GNS3.app/Contents/Resources/VBoxWrapper')
print '*** Making DMG ***'
os.system("/usr/bin/macdeployqt GNS3.app -dmg -no-plugins")
else:
def normalizeWhitespace(s):
return ' '.join(s.split())
if platform.system() == 'Linux':
wrapper_dir = '/usr/share/gns3/'
else:
wrapper_dir = '/usr/local/libexec/gns3/'
setup( # Distribution meta-data
name = 'GNS3',
version = VERSION,
description = 'Network simulator that allows simulation of advanced networks',
long_description = normalizeWhitespace("""
Based on Dynamips, an IOS emulator which allows users to run IOS binary images
from Cisco Systems and Qemu/VirtualBox for emulating PIX & ASA
firewalls as well as Juniper routers and Cisco IDS/IPS.
Important: binary images are not part of this package."""),
license = 'GNU General Public License (GPLv2)',
author = 'Jeremy Grossmann',
author_email = '[email protected]',
maintainer = 'Jeremy Grossmann',
maintainer_email = '[email protected]',
keywords = ['network', 'simulator', 'cisco', 'junos', 'ios'],
platforms = [ 'Windows', 'Linux', 'BSD', 'Mac OS X' ],
url = 'http://www.gns3.net/',
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: X11 Applications :: Qt',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Natural Language :: English',
'Programming Language :: Python',
'Topic :: System :: Networking'],
scripts = [ 'gns3' ],
package_dir = { '': 'src' },
packages = [
'GNS3',
'GNS3.Awp',
'GNS3.Config',
'GNS3.Globals',
'GNS3.Dynagen',
'GNS3.Defaults',
'GNS3.External',
'GNS3.Export',
'GNS3.Link',
'GNS3.Node',
'GNS3.Ui',
'GNS3.Ui.ConfigurationPages',
'GNS3.Langs'],
package_data = { 'GNS3': ['Langs/*.qm', 'Dynagen/configspec'] },
data_files = [ (wrapper_dir, ['qemuwrapper/qemuwrapper.py', 'vboxwrapper/vboxcontroller_4_1.py', 'vboxwrapper/vboxwrapper.py', 'vboxwrapper/tcp_pipe_proxy.py']),
('/usr/local/share/examples/gns3/', ['baseconfig.txt', 'baseconfig_sw.txt']),
('/usr/local/share/doc/gns3/', ['README', 'COPYING', 'CHANGELOG']),
('/usr/local/share/man/man1/', ['docs/man/gns3.1'])]
)