forked from netzob/netzob
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
257 lines (224 loc) · 11.7 KB
/
setup.py
File metadata and controls
257 lines (224 loc) · 11.7 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# +---------------------------------------------------------------------------+
# | 01001110 01100101 01110100 01111010 01101111 01100010 |
# | |
# | Netzob : Inferring communication protocols |
# +---------------------------------------------------------------------------+
# | Copyright (C) 2011_2014 Georges Bossert and Frédéric Guihéry |
# | This program is free software: you can redistribute it and/or modify |
# | it under the terms of the GNU General Public License as published by |
# | the Free Software Foundation, either version 3 of the License, or |
# | (at your option) any later version. |
# | |
# | This program is distributed in the hope that it will be useful, |
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# | GNU General Public License for more details. |
# | |
# | You should have received a copy of the GNU General Public License |
# | along with this program. If not, see <http://www.gnu.org/licenses/>. |
# +---------------------------------------------------------------------------+
# | @url : http://www.netzob.org |
# | @contact : contact@netzob.org |
# | @sponsors : Amossys, http://www.amossys.fr |
# | Supélec, http://www.rennes.supelec.fr/ren/rd/cidre/ |
# +---------------------------------------------------------------------------+
# +----------------------------------------------------------------------------
# | Global Imports
# +----------------------------------------------------------------------------
import sys
import os
import uuid
from setuptools import setup, Extension, find_packages
sys.path.insert(0, 'src/')
from netzob import release
from resources.sdist.pybuild_command import pybuild_command
from resources.sdist.test_command import test_command
from resources.sdist.utils import find_data_files, opj, getPluginPaths
# +----------------------------------------------------------------------------
# | Definition of variables
# +----------------------------------------------------------------------------
# Path to the resources
staticResourcesPath = opj("resources", "static")
netzobStaticResourcesPath = opj(staticResourcesPath, "netzob")
# +----------------------------------------------------------------------------
# | Compute the compilation arguments given the current compilation profile
# +----------------------------------------------------------------------------
# compileProfile = "[no-verify] devel|release"
#
# Note :
# if defined, the environment variable "NETZOB_COMPILE_PROFILE" sets
# the compileProfile
#
# Available compilation profile
# - devel : no optimization, include debugging symbols and stop on compilation warnings
# - release : activate optimization and symbols are stripped (default mode)
# Static analysis
# - no-verify : deactivate the source code static analysis while compiling
#
# TODO : an unoptimized profile with options like -mno-mmx, -mno-sse,
# -mno-sse2, -mno-3dnow, -fno-dwarf2-cfi-asm
#
compileProfile = "release"
NETZOB_COMPILE_PROFILE_ENV = "NETZOB_COMPILE_PROFILE"
# extract requested mode from the environment variable
if NETZOB_COMPILE_PROFILE_ENV in os.environ.keys():
compileProfile = os.environ[NETZOB_COMPILE_PROFILE_ENV]
# Default compile arguments
extraCompileArgs = ["-std=c99"]
if "no-verify" not in compileProfile:
extraCompileArgs.extend([
"-Wall", # gcc says: "Enable most warning messages"
"-Wextra", # gcc says: "Print extra (possibly unwanted) warnings"
"-Wunused", # gcc says: "Enable all -Wunused- warnings"
"-Wsign-compare", # gcc says: "Warn about signed-unsigned comparisons"
"-Wstrict-prototypes", # gcc says: "Warn about unprototyped function declarations"
"-Wuninitialized", # gcc says: "Warn about uninitialized automatic variables"
"-Wshadow", # gcc says: "Warn when one local variable shadows another"
"-Wpointer-arith"]) # gcc says: "Warn about function pointer arithmetic"
if "devel" in compileProfile:
extraCompileArgs.extend([
"-O0", # gcc says: "Optimization level 0"
"-Werror", # gcc says: "Error out the compiler on warnings"
"-pedantic-errors", # gcc says: "Issue errors "needed for strict compliance to the standard"
"-g"]) # gcc says: "Generate debug information in default format"
elif "release" in compileProfile:
extraCompileArgs.extend([
"-O2"]) # gcc says: "Optimization level 2"
# +----------------------------------------------------------------------------
# | Definition of the extensions
# +----------------------------------------------------------------------------
# Includes path
libPath = "lib"
includesPath = opj(libPath, "includes")
pyIncludesPath = opj(includesPath, "Py_lib")
includes = [includesPath, pyIncludesPath]
# Interface path
interfacePath = opj(libPath, "interface")
pyInterfacePath = opj(interfacePath, "Py_lib")
# Needleman path
needlemanPath = opj(libPath, "libNeedleman")
pyNeedlemanPath = opj(needlemanPath, "Py_lib")
# ArgsFactories path
argsFactoriesPath = opj(libPath, "argsFactories")
# Relation path
relPath = os.path.join(libPath, "libRelation")
pyRelPath = os.path.join(relPath, "Py_lib")
relImplPath = os.path.join(relPath, "algorithms")
# Tools path
toolsPath = opj(libPath, "tools")
# Generate the random binary identifier BID
macros = [('BID', '"{0}"'.format(str(uuid.uuid4())))]
# Module Needleman
moduleLibNeedleman = Extension('netzob._libNeedleman',
extra_compile_args=extraCompileArgs,
sources=[opj(interfacePath, "Interface.c"),
opj(pyInterfacePath, "libInterface.c"),
opj(pyNeedlemanPath, "libNeedleman.c"),
opj(needlemanPath, "Needleman.c"),
opj(needlemanPath, "scoreComputation.c"),
opj(argsFactoriesPath, "factory.c"),
opj(toolsPath, "getBID.c")],
define_macros=macros,
include_dirs=includes)
# Module ScoreComputation
moduleLibScoreComputation = Extension('netzob._libScoreComputation',
extra_compile_args=extraCompileArgs,
sources=[opj(needlemanPath, "scoreComputation.c"),
opj(pyNeedlemanPath, "libScoreComputation.c"),
opj(needlemanPath, "Needleman.c"),
opj(interfacePath, "Interface.c"),
opj(pyInterfacePath, "libInterface.c"),
opj(argsFactoriesPath, "factory.c"),
opj(toolsPath, "getBID.c")],
define_macros=macros,
include_dirs=includes)
# Module Interface
moduleLibInterface = Extension('netzob._libInterface',
extra_compile_args=extraCompileArgs,
sources=[opj(interfacePath, "Interface.c"),
opj(pyInterfacePath, "libInterface.c"),
opj(toolsPath, "getBID.c")],
define_macros=macros,
include_dirs=includes)
# Module Relation
moduleLibRelation = Extension('netzob._libRelation',
extra_compile_args=extraCompileArgs,
sources=[os.path.join(relPath, "relation.c"),
os.path.join(pyRelPath, "libRelation.c")],
define_macros=macros,
include_dirs=includes,
libraries=["dl"])
# +----------------------------------------------------------------------------
# | Definition of the dependencies
# +----------------------------------------------------------------------------
dependencies = []
with open('requirements.txt', 'r') as fd_requirements:
for dependency in fd_requirements:
dependencies.append(dependency.strip())
extra_dependencies = {
'docs': ['Sphinx>=1.1.3'],
'network': ['pcapy>=0.10.8', 'impacket>=0.9.12'],
'correlation': ['numpy>=1.9.2', 'minepy>=1.0.0']
}
dependency_links = []
# +----------------------------------------------------------------------------
# | Extensions in the build operations (create manpage, i18n, ...)
# +----------------------------------------------------------------------------
CMD_CLASS = {
'build_py': pybuild_command,
'test': test_command
}
# +----------------------------------------------------------------------------
root_data_files = find_data_files(opj("share", "netzob"), netzobStaticResourcesPath, 'logo.png', recursive=False)
app_data_files = find_data_files(opj("share", "applications"), netzobStaticResourcesPath, 'netzob.desktop', recursive=False)
icons_data_files = find_data_files(opj("share", "netzob", "icons"), opj(netzobStaticResourcesPath, "icons"), '*.png')
default_data_files = find_data_files(opj("share", "netzob", "defaults"), opj(netzobStaticResourcesPath, "defaults"), '*.default', recursive=False)
data_files = root_data_files + app_data_files + icons_data_files + default_data_files
# Extract the long description from README.rst and NEWS.rst files
README = open('README.rst', 'rt').read()
NEWS = open('NEWS.rst', 'rt').read()
# +----------------------------------------------------------------------------
# | Definition of Netzob for setup
# +----------------------------------------------------------------------------
setup(
name=release.name,
packages=find_packages(where='src'),
package_dir={
"": "src",
},
ext_modules=[moduleLibNeedleman, moduleLibScoreComputation, moduleLibInterface, moduleLibRelation],
data_files=data_files,
scripts=["netzob"],
install_requires=dependencies,
extras_require=extra_dependencies,
dependency_links=dependency_links,
version=release.version,
license=release.licenseName,
description=release.description,
platforms=release.platforms,
author=release.author,
author_email=release.author_email,
url=release.url,
download_url=release.download_url,
keywords=release.keywords,
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: C",
"Development Status :: 4 - Beta",
"Environment :: X11 Applications :: GTK",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Natural Language :: English",
"Natural Language :: French",
"Topic :: Security",
"Topic :: System :: Networking"
],
long_description=README + '\n' + NEWS,
cmdclass=CMD_CLASS,
)