lief 0.8.0__zip → 0.8.1__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lief might be problematic. Click here for more details.
- {lief-0.8.0 → lief-0.8.1}/MANIFEST.in +1 -1
- {lief-0.8.0 → lief-0.8.1}/PKG-INFO +27 -27
- {lief-0.8.0 → lief-0.8.1}/README +15 -15
- {lief-0.8.0 → lief-0.8.1}/lief/__init__.py +15 -15
- {lief-0.8.0 → lief-0.8.1}/lief.egg-info/PKG-INFO +27 -27
- {lief-0.8.0 → lief-0.8.1}/lief.egg-info/not-zip-safe +1 -1
- {lief-0.8.0 → lief-0.8.1}/setup.cfg +33 -33
- {lief-0.8.0 → lief-0.8.1}/setup.py +283 -277
- {lief-0.8.0 → lief-0.8.1}/lief.egg-info/SOURCES.txt +0 -0
- {lief-0.8.0 → lief-0.8.1}/lief.egg-info/dependency_links.txt +0 -0
- {lief-0.8.0 → lief-0.8.1}/lief.egg-info/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
include README setup.cfg
|
|
1
|
+
include README setup.cfg
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: lief
|
|
3
|
-
Version: 0.8.
|
|
4
|
-
Summary: LIEF is a library to instrument executable formats
|
|
5
|
-
Home-page: https://lief.quarkslab.com
|
|
6
|
-
Author: Romain Thomas
|
|
7
|
-
Author-email: rthomas@quarkslab.com
|
|
8
|
-
License: Apache 2.0
|
|
9
|
-
Description-Content-Type: UNKNOWN
|
|
10
|
-
Description: UNKNOWN
|
|
11
|
-
Keywords: parser,elf,pe,macho
|
|
12
|
-
Platform: UNKNOWN
|
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
-
Classifier: Development Status :: 4 - Beta
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
|
-
Classifier: Intended Audience :: Developers
|
|
17
|
-
Classifier: Intended Audience :: Science/Research
|
|
18
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
-
Classifier: Programming Language :: C++
|
|
22
|
-
Classifier: Programming Language :: Python :: 2
|
|
23
|
-
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
-
Classifier: Topic :: Security
|
|
26
|
-
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
27
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
1
|
+
Metadata-Version: 1.1
|
|
2
|
+
Name: lief
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: LIEF is a library to instrument executable formats
|
|
5
|
+
Home-page: https://lief.quarkslab.com
|
|
6
|
+
Author: Romain Thomas
|
|
7
|
+
Author-email: rthomas@quarkslab.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Description-Content-Type: UNKNOWN
|
|
10
|
+
Description: UNKNOWN
|
|
11
|
+
Keywords: parser,elf,pe,macho
|
|
12
|
+
Platform: UNKNOWN
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
+
Classifier: Programming Language :: C++
|
|
22
|
+
Classifier: Programming Language :: Python :: 2
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
27
|
+
Classifier: Topic :: Software Development :: Build Tools
|
{lief-0.8.0 → lief-0.8.1}/README
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
LIEF - Python API
|
|
2
|
-
-----------------
|
|
3
|
-
|
|
4
|
-
The purpose of this project is to provide a cross platform library which can parse, modify and abstract ELF, PE and MachO formats.
|
|
5
|
-
|
|
6
|
-
Main features:
|
|
7
|
-
|
|
8
|
-
* Parsing: LIEF can parse ELF, PE, MachO and provides an user-friendly API to access to format internals.
|
|
9
|
-
* Modify: LIEF enables to modify some parts of these formats
|
|
10
|
-
* Abstract: Three formats have common features like sections, symbols, entry point... LIEF factors them.
|
|
11
|
-
* API: LIEF can be used in C, C++ and Python
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
LIEF - Python API
|
|
2
|
+
-----------------
|
|
3
|
+
|
|
4
|
+
The purpose of this project is to provide a cross platform library which can parse, modify and abstract ELF, PE and MachO formats.
|
|
5
|
+
|
|
6
|
+
Main features:
|
|
7
|
+
|
|
8
|
+
* Parsing: LIEF can parse ELF, PE, MachO and provides an user-friendly API to access to format internals.
|
|
9
|
+
* Modify: LIEF enables to modify some parts of these formats
|
|
10
|
+
* Abstract: Three formats have common features like sections, symbols, entry point... LIEF factors them.
|
|
11
|
+
* API: LIEF can be used in C, C++ and Python
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import _pylief
|
|
5
|
-
from _pylief import *
|
|
6
|
-
|
|
7
|
-
__version__ = _pylief.__version__
|
|
8
|
-
|
|
9
|
-
sys.modules["lief.PE"] = _pylief.PE
|
|
10
|
-
sys.modules["lief.ELF"] = _pylief.ELF
|
|
11
|
-
|
|
12
|
-
sys.modules["lief.ELF.ELF32"] = _pylief.ELF.ELF32
|
|
13
|
-
sys.modules["lief.ELF.ELF64"] = _pylief.ELF.ELF64
|
|
14
|
-
|
|
15
|
-
sys.modules["lief.MachO"] = _pylief.MachO
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import _pylief
|
|
5
|
+
from _pylief import *
|
|
6
|
+
|
|
7
|
+
__version__ = _pylief.__version__
|
|
8
|
+
|
|
9
|
+
sys.modules["lief.PE"] = _pylief.PE
|
|
10
|
+
sys.modules["lief.ELF"] = _pylief.ELF
|
|
11
|
+
|
|
12
|
+
sys.modules["lief.ELF.ELF32"] = _pylief.ELF.ELF32
|
|
13
|
+
sys.modules["lief.ELF.ELF64"] = _pylief.ELF.ELF64
|
|
14
|
+
|
|
15
|
+
sys.modules["lief.MachO"] = _pylief.MachO
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: lief
|
|
3
|
-
Version: 0.8.
|
|
4
|
-
Summary: LIEF is a library to instrument executable formats
|
|
5
|
-
Home-page: https://lief.quarkslab.com
|
|
6
|
-
Author: Romain Thomas
|
|
7
|
-
Author-email: rthomas@quarkslab.com
|
|
8
|
-
License: Apache 2.0
|
|
9
|
-
Description-Content-Type: UNKNOWN
|
|
10
|
-
Description: UNKNOWN
|
|
11
|
-
Keywords: parser,elf,pe,macho
|
|
12
|
-
Platform: UNKNOWN
|
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
-
Classifier: Development Status :: 4 - Beta
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
|
-
Classifier: Intended Audience :: Developers
|
|
17
|
-
Classifier: Intended Audience :: Science/Research
|
|
18
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
-
Classifier: Programming Language :: C++
|
|
22
|
-
Classifier: Programming Language :: Python :: 2
|
|
23
|
-
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
-
Classifier: Topic :: Security
|
|
26
|
-
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
27
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
1
|
+
Metadata-Version: 1.1
|
|
2
|
+
Name: lief
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: LIEF is a library to instrument executable formats
|
|
5
|
+
Home-page: https://lief.quarkslab.com
|
|
6
|
+
Author: Romain Thomas
|
|
7
|
+
Author-email: rthomas@quarkslab.com
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Description-Content-Type: UNKNOWN
|
|
10
|
+
Description: UNKNOWN
|
|
11
|
+
Keywords: parser,elf,pe,macho
|
|
12
|
+
Platform: UNKNOWN
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
21
|
+
Classifier: Programming Language :: C++
|
|
22
|
+
Classifier: Programming Language :: Python :: 2
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
27
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
[metadata]
|
|
2
|
-
name = lief
|
|
3
|
-
description = LIEF is a library to instrument executable formats
|
|
4
|
-
author = Romain Thomas
|
|
5
|
-
author_email = rthomas@quarkslab.com
|
|
6
|
-
url = https://lief.quarkslab.com
|
|
7
|
-
license = Apache 2.0
|
|
8
|
-
keywords = parser, elf, pe, macho
|
|
9
|
-
classifiers =
|
|
10
|
-
License :: OSI Approved :: Apache Software License
|
|
11
|
-
Development Status :: 4 - Beta
|
|
12
|
-
Environment :: Console
|
|
13
|
-
Intended Audience :: Developers
|
|
14
|
-
Intended Audience :: Science/Research
|
|
15
|
-
Operating System :: MacOS :: MacOS X
|
|
16
|
-
Operating System :: POSIX :: Linux
|
|
17
|
-
Operating System :: Microsoft :: Windows
|
|
18
|
-
Programming Language :: C++
|
|
19
|
-
Programming Language :: Python :: 2
|
|
20
|
-
Programming Language :: Python :: 3
|
|
21
|
-
Topic :: Software Development :: Libraries
|
|
22
|
-
Topic :: Security
|
|
23
|
-
Topic :: Scientific/Engineering :: Information Analysis
|
|
24
|
-
Topic :: Software Development :: Build Tools
|
|
25
|
-
|
|
26
|
-
[options]
|
|
27
|
-
zip_safe = False
|
|
28
|
-
packages = lief
|
|
29
|
-
|
|
30
|
-
[egg_info]
|
|
31
|
-
tag_build =
|
|
32
|
-
tag_date = 0
|
|
33
|
-
|
|
1
|
+
[metadata]
|
|
2
|
+
name = lief
|
|
3
|
+
description = LIEF is a library to instrument executable formats
|
|
4
|
+
author = Romain Thomas
|
|
5
|
+
author_email = rthomas@quarkslab.com
|
|
6
|
+
url = https://lief.quarkslab.com
|
|
7
|
+
license = Apache 2.0
|
|
8
|
+
keywords = parser, elf, pe, macho
|
|
9
|
+
classifiers =
|
|
10
|
+
License :: OSI Approved :: Apache Software License
|
|
11
|
+
Development Status :: 4 - Beta
|
|
12
|
+
Environment :: Console
|
|
13
|
+
Intended Audience :: Developers
|
|
14
|
+
Intended Audience :: Science/Research
|
|
15
|
+
Operating System :: MacOS :: MacOS X
|
|
16
|
+
Operating System :: POSIX :: Linux
|
|
17
|
+
Operating System :: Microsoft :: Windows
|
|
18
|
+
Programming Language :: C++
|
|
19
|
+
Programming Language :: Python :: 2
|
|
20
|
+
Programming Language :: Python :: 3
|
|
21
|
+
Topic :: Software Development :: Libraries
|
|
22
|
+
Topic :: Security
|
|
23
|
+
Topic :: Scientific/Engineering :: Information Analysis
|
|
24
|
+
Topic :: Software Development :: Build Tools
|
|
25
|
+
|
|
26
|
+
[options]
|
|
27
|
+
zip_safe = False
|
|
28
|
+
packages = lief
|
|
29
|
+
|
|
30
|
+
[egg_info]
|
|
31
|
+
tag_build =
|
|
32
|
+
tag_date = 0
|
|
33
|
+
|
|
@@ -1,277 +1,283 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
from setuptools
|
|
10
|
-
from setuptools.command.
|
|
11
|
-
|
|
12
|
-
from setuptools.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
try:
|
|
29
|
-
from
|
|
30
|
-
except:
|
|
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
|
-
def
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if fmt == '
|
|
99
|
-
fmt = 'tar.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
name=self.distribution.get_name(),
|
|
109
|
-
version=lief_version,
|
|
110
|
-
ext=fmt)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
platform=os_version,
|
|
151
|
-
version=lief_version,
|
|
152
|
-
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
153
|
-
ext="egg")
|
|
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
|
-
platform=os_version,
|
|
231
|
-
version=lief_version,
|
|
232
|
-
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
233
|
-
ext="egg")
|
|
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
|
-
)
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
MIN_SETUPTOOLS_VERSION = "36.4.0"
|
|
5
|
+
import setuptools
|
|
6
|
+
from distutils.version import LooseVersion
|
|
7
|
+
assert (LooseVersion(setuptools.__version__) >= LooseVersion(MIN_SETUPTOOLS_VERSION)), "LIEF requires a setuptools version '{}' or higher".format(MIN_SETUPTOOLS_VERSION)
|
|
8
|
+
|
|
9
|
+
from setuptools import setup
|
|
10
|
+
from setuptools.command.build_ext import build_ext
|
|
11
|
+
from distutils.dir_util import remove_tree, mkpath
|
|
12
|
+
from setuptools.command.bdist_egg import bdist_egg
|
|
13
|
+
from setuptools.command.bdist_egg import log as bdist_egg_log
|
|
14
|
+
|
|
15
|
+
from setuptools.command.sdist import sdist
|
|
16
|
+
from setuptools.command.sdist import log as sdist_log
|
|
17
|
+
|
|
18
|
+
from setuptools.extension import Extension
|
|
19
|
+
|
|
20
|
+
import re
|
|
21
|
+
import os
|
|
22
|
+
import platform
|
|
23
|
+
import shutil
|
|
24
|
+
import sys
|
|
25
|
+
import struct
|
|
26
|
+
import zipfile
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
from urllib.request import urlopen, Request
|
|
30
|
+
except:
|
|
31
|
+
from urllib2 import urlopen, Request
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
from io import BytesIO
|
|
36
|
+
except:
|
|
37
|
+
try:
|
|
38
|
+
from cStringIO import StringIO as BytesIO
|
|
39
|
+
except:
|
|
40
|
+
from StringIO import StringIO as BytesIO
|
|
41
|
+
|
|
42
|
+
package_dir = os.path.dirname(os.path.realpath(__file__))
|
|
43
|
+
pkg_info = os.path.join(package_dir, "PKG-INFO")
|
|
44
|
+
in_source_package = os.path.isfile(pkg_info) # (e.g. pip)
|
|
45
|
+
|
|
46
|
+
is_branch = False
|
|
47
|
+
|
|
48
|
+
libpylief = {
|
|
49
|
+
'Windows': "_pylief.pyd",
|
|
50
|
+
'Darwin': "_pylief.so",
|
|
51
|
+
'Linux': "_pylief.so",
|
|
52
|
+
}
|
|
53
|
+
version_re = r"Version:\s+(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(.*)"
|
|
54
|
+
if in_source_package:
|
|
55
|
+
with open(pkg_info, "r") as f:
|
|
56
|
+
major, minor, patch, branch = re.findall(version_re, f.read(), re.MULTILINE)[0]
|
|
57
|
+
lief_version = "{:d}.{:d}.{:d}".format(int(major), int(minor), int(patch))
|
|
58
|
+
is_branch = len(branch.strip()) > 0
|
|
59
|
+
else:
|
|
60
|
+
lief_version = "0.8.1"
|
|
61
|
+
|
|
62
|
+
package_description = open(os.path.join(package_dir, "README")).read()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_lief_platform_name():
|
|
66
|
+
system = platform.system()
|
|
67
|
+
arch = struct.calcsize('P') * 8
|
|
68
|
+
|
|
69
|
+
if system == 'Windows':
|
|
70
|
+
return "windows_x64" if arch == 64 else "windows_x32"
|
|
71
|
+
elif system == 'Darwin':
|
|
72
|
+
return "osx" if arch == 64 else "osx_x32"
|
|
73
|
+
elif system == 'Linux':
|
|
74
|
+
return "linux" if arch == 64 else "linux_x32"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class lief_sdist(sdist):
|
|
78
|
+
|
|
79
|
+
user_options = sdist.user_options + [
|
|
80
|
+
('dev', None, "Add a dev marker")
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
def initialize_options(self):
|
|
84
|
+
sdist.initialize_options(self)
|
|
85
|
+
self.dev = 0
|
|
86
|
+
|
|
87
|
+
def run(self):
|
|
88
|
+
if self.dev:
|
|
89
|
+
suffix = '.dev-{:s}'.format("f4e2ae0")
|
|
90
|
+
self.distribution.metadata.version += suffix
|
|
91
|
+
sdist.run(self)
|
|
92
|
+
|
|
93
|
+
def make_distribution(self):
|
|
94
|
+
sdist.make_distribution(self)
|
|
95
|
+
base_dir = self.distribution.get_fullname()
|
|
96
|
+
base_name = os.path.join(self.dist_dir, base_dir)
|
|
97
|
+
for fmt in self.formats:
|
|
98
|
+
if fmt == 'gztar':
|
|
99
|
+
fmt = 'tar.gz'
|
|
100
|
+
|
|
101
|
+
if fmt == 'bztar':
|
|
102
|
+
fmt = 'tar.bz2'
|
|
103
|
+
|
|
104
|
+
if fmt == 'ztar':
|
|
105
|
+
fmt = 'tar.Z'
|
|
106
|
+
|
|
107
|
+
new_name = "py{name}-{version}.{ext}".format(
|
|
108
|
+
name=self.distribution.get_name(),
|
|
109
|
+
version=lief_version,
|
|
110
|
+
ext=fmt)
|
|
111
|
+
|
|
112
|
+
if self.dev:
|
|
113
|
+
new_name = "py{name}-{version}.dev.{ext}".format(
|
|
114
|
+
name=self.distribution.get_name(),
|
|
115
|
+
version=lief_version,
|
|
116
|
+
ext=fmt)
|
|
117
|
+
new_name = os.path.join(self.dist_dir, new_name)
|
|
118
|
+
shutil.move(base_name + "." + fmt, new_name)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class lief_bdist_egg(bdist_egg):
|
|
124
|
+
def initialize_options(self):
|
|
125
|
+
bdist_egg.initialize_options(self)
|
|
126
|
+
|
|
127
|
+
if not in_source_package:
|
|
128
|
+
self.plat_name = get_lief_platform_name()
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def run(self):
|
|
132
|
+
if in_source_package:
|
|
133
|
+
self._build_from_source_package()
|
|
134
|
+
else:
|
|
135
|
+
bdist_egg.run(self)
|
|
136
|
+
|
|
137
|
+
def _build_from_source_package(self):
|
|
138
|
+
python_version = sys.version_info
|
|
139
|
+
python_major_version = python_version[0]
|
|
140
|
+
os_version = get_lief_platform_name()
|
|
141
|
+
|
|
142
|
+
url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
143
|
+
url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
144
|
+
url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
145
|
+
|
|
146
|
+
url = ""
|
|
147
|
+
if is_branch:
|
|
148
|
+
url = url_branch_fmt.format(
|
|
149
|
+
branch='master',
|
|
150
|
+
platform=os_version,
|
|
151
|
+
version=lief_version,
|
|
152
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
153
|
+
ext="egg")
|
|
154
|
+
else:
|
|
155
|
+
url = url_release_fmt.format(
|
|
156
|
+
platform=os_version,
|
|
157
|
+
version=lief_version,
|
|
158
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
159
|
+
ext="egg")
|
|
160
|
+
|
|
161
|
+
bdist_egg_log.info("Url: {}".format(url))
|
|
162
|
+
egg_data = None
|
|
163
|
+
network_error = None
|
|
164
|
+
try:
|
|
165
|
+
egg_data = urlopen(url).read()
|
|
166
|
+
except Exception as e:
|
|
167
|
+
network_error = e
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if network_error is not None:
|
|
171
|
+
bdist_egg_log.warn(network_error)
|
|
172
|
+
url = url_userpath.format(
|
|
173
|
+
platform=os_version,
|
|
174
|
+
version=lief_version,
|
|
175
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
176
|
+
ext="egg")
|
|
177
|
+
url = os.path.expanduser(url)
|
|
178
|
+
if os.path.isfile(url):
|
|
179
|
+
with open(url, 'rb') as f:
|
|
180
|
+
egg_data = f.read()
|
|
181
|
+
else:
|
|
182
|
+
raise Exception("Unable to find {}".format(url))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
egg_file = BytesIO(egg_data)
|
|
186
|
+
|
|
187
|
+
mkpath(os.path.dirname(self.egg_output))
|
|
188
|
+
|
|
189
|
+
bdist_egg_log.info("Output: {}".format(self.egg_output))
|
|
190
|
+
with open(self.egg_output, 'wb') as f:
|
|
191
|
+
f.write(egg_file.getvalue())
|
|
192
|
+
|
|
193
|
+
getattr(self.distribution, 'dist_files', []).append(
|
|
194
|
+
('bdist_egg', "{}.{}".format(python_version[0], python_version[1]), self.egg_output))
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class lief_build_ext(build_ext):
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def build_extension(self, ext):
|
|
202
|
+
self.target = self.get_ext_fullpath(ext.name)
|
|
203
|
+
target_dir = os.path.dirname(self.target)
|
|
204
|
+
|
|
205
|
+
try:
|
|
206
|
+
os.makedirs(target_dir)
|
|
207
|
+
except:
|
|
208
|
+
pass
|
|
209
|
+
|
|
210
|
+
if in_source_package:
|
|
211
|
+
self._install_from_source_package()
|
|
212
|
+
else:
|
|
213
|
+
shutil.copyfile(libpylief[platform.system()], self.target)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _install_from_source_package(self):
|
|
217
|
+
python_version = sys.version_info
|
|
218
|
+
python_major_version = python_version[0]
|
|
219
|
+
os_version = get_lief_platform_name()
|
|
220
|
+
target_extension = os.path.splitext(self.target)[1]
|
|
221
|
+
|
|
222
|
+
url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
223
|
+
url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
224
|
+
url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
|
|
225
|
+
|
|
226
|
+
url = ""
|
|
227
|
+
if is_branch:
|
|
228
|
+
url = url_branch_fmt.format(
|
|
229
|
+
branch='master',
|
|
230
|
+
platform=os_version,
|
|
231
|
+
version=lief_version,
|
|
232
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
233
|
+
ext="egg")
|
|
234
|
+
else:
|
|
235
|
+
url = url_release_fmt.format(
|
|
236
|
+
platform=os_version,
|
|
237
|
+
version=lief_version,
|
|
238
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
239
|
+
ext="egg")
|
|
240
|
+
|
|
241
|
+
bdist_egg_log.info("Url: {}".format(url))
|
|
242
|
+
egg_data = None
|
|
243
|
+
network_error = None
|
|
244
|
+
try:
|
|
245
|
+
egg_data = urlopen(url).read()
|
|
246
|
+
except Exception as e:
|
|
247
|
+
network_error = e
|
|
248
|
+
|
|
249
|
+
if network_error is not None:
|
|
250
|
+
bdist_egg_log.warn(network_error)
|
|
251
|
+
url = url_userpath.format(
|
|
252
|
+
platform=os_version,
|
|
253
|
+
version=lief_version,
|
|
254
|
+
pyversion="{}.{}".format(python_version[0], python_version[1]),
|
|
255
|
+
ext="egg")
|
|
256
|
+
url = os.path.expanduser(url)
|
|
257
|
+
if os.path.isfile(url):
|
|
258
|
+
with open(url, 'rb') as f:
|
|
259
|
+
egg_data = f.read()
|
|
260
|
+
else:
|
|
261
|
+
raise Exception("Unable to find {}".format(url))
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
egg_file = BytesIO(egg_data)
|
|
268
|
+
|
|
269
|
+
egg_zip = zipfile.ZipFile(egg_file)
|
|
270
|
+
extension_member = [info for info in egg_zip.infolist() if info.filename.endswith(target_extension)][0]
|
|
271
|
+
extension_data = egg_zip.read(extension_member)
|
|
272
|
+
with open(self.target, 'wb') as f:
|
|
273
|
+
f.write(extension_data)
|
|
274
|
+
|
|
275
|
+
setup(
|
|
276
|
+
version = lief_version,
|
|
277
|
+
ext_modules = [Extension('_pylief', [])],
|
|
278
|
+
cmdclass={
|
|
279
|
+
'build_ext': lief_build_ext,
|
|
280
|
+
'bdist_egg': lief_bdist_egg,
|
|
281
|
+
'sdist': lief_sdist
|
|
282
|
+
},
|
|
283
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|