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.

@@ -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.0
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,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.0
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
- from setuptools import setup
4
- from setuptools.command.build_ext import build_ext
5
- from distutils.dir_util import remove_tree, mkpath
6
- from setuptools.command.bdist_egg import bdist_egg
7
- from setuptools.command.bdist_egg import log as bdist_egg_log
8
-
9
- from setuptools.command.sdist import sdist
10
- from setuptools.command.sdist import log as sdist_log
11
-
12
- from setuptools.extension import Extension
13
-
14
- import re
15
- import os
16
- import platform
17
- import shutil
18
- import sys
19
- import struct
20
- import zipfile
21
-
22
- try:
23
- from urllib.request import urlopen, Request
24
- except:
25
- from urllib2 import urlopen, Request
26
-
27
-
28
- try:
29
- from io import BytesIO
30
- except:
31
- try:
32
- from cStringIO import StringIO as BytesIO
33
- except:
34
- from StringIO import StringIO as BytesIO
35
-
36
- package_dir = os.path.dirname(os.path.realpath(__file__))
37
- pkg_info = os.path.join(package_dir, "PKG-INFO")
38
- in_source_package = os.path.isfile(pkg_info) # (e.g. pip)
39
-
40
- is_branch = False
41
-
42
- libpylief = {
43
- 'Windows': "_pylief.pyd",
44
- 'Darwin': "_pylief.so",
45
- 'Linux': "_pylief.so",
46
- }
47
- version_re = r"Version:\s+(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(.*)"
48
- if in_source_package:
49
- with open(pkg_info, "r") as f:
50
- major, minor, patch, branch = re.findall(version_re, f.read(), re.MULTILINE)[0]
51
- lief_version = "{:d}.{:d}.{:d}".format(int(major), int(minor), int(patch))
52
- is_branch = len(branch.strip()) > 0
53
- else:
54
- lief_version = "0.8.0"
55
-
56
- package_description = open(os.path.join(package_dir, "README")).read()
57
-
58
-
59
- def get_lief_platform_name():
60
- system = platform.system()
61
- arch = struct.calcsize('P') * 8
62
-
63
- if system == 'Windows':
64
- return "windows_x64" if arch == 64 else "windows_x32"
65
- elif system == 'Darwin':
66
- return "osx" if arch == 64 else "osx_x32"
67
- elif system == 'Linux':
68
- return "linux" if arch == 64 else "linux_x32"
69
-
70
-
71
- class lief_sdist(sdist):
72
-
73
- user_options = sdist.user_options + [
74
- ('dev', None, "Add a dev marker")
75
- ]
76
-
77
- def initialize_options(self):
78
- sdist.initialize_options(self)
79
- self.dev = 0
80
-
81
- def run(self):
82
- if self.dev:
83
- suffix = '.dev-{:s}'.format("0d14f9e")
84
- self.distribution.metadata.version += suffix
85
- sdist.run(self)
86
-
87
- def make_distribution(self):
88
- sdist.make_distribution(self)
89
- base_dir = self.distribution.get_fullname()
90
- base_name = os.path.join(self.dist_dir, base_dir)
91
- for fmt in self.formats:
92
- if fmt == 'gztar':
93
- fmt = 'tar.gz'
94
-
95
- if fmt == 'bztar':
96
- fmt = 'tar.bz2'
97
-
98
- if fmt == 'ztar':
99
- fmt = 'tar.Z'
100
-
101
- new_name = "py{name}-{version}.{ext}".format(
102
- name=self.distribution.get_name(),
103
- version=lief_version,
104
- ext=fmt)
105
-
106
- if self.dev:
107
- new_name = "py{name}-{version}.dev.{ext}".format(
108
- name=self.distribution.get_name(),
109
- version=lief_version,
110
- ext=fmt)
111
- new_name = os.path.join(self.dist_dir, new_name)
112
- shutil.move(base_name + "." + fmt, new_name)
113
-
114
-
115
-
116
-
117
- class lief_bdist_egg(bdist_egg):
118
- def initialize_options(self):
119
- bdist_egg.initialize_options(self)
120
-
121
- if not in_source_package:
122
- self.plat_name = get_lief_platform_name()
123
-
124
-
125
- def run(self):
126
- if in_source_package:
127
- self._build_from_source_package()
128
- else:
129
- bdist_egg.run(self)
130
-
131
- def _build_from_source_package(self):
132
- python_version = sys.version_info
133
- python_major_version = python_version[0]
134
- os_version = get_lief_platform_name()
135
-
136
- url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
137
- url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
138
- url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
139
-
140
- url = ""
141
- if is_branch:
142
- url = url_branch_fmt.format(
143
- branch='master',
144
- platform=os_version,
145
- version=lief_version,
146
- pyversion="{}.{}".format(python_version[0], python_version[1]),
147
- ext="egg")
148
- else:
149
- url = url_release_fmt.format(
150
- platform=os_version,
151
- version=lief_version,
152
- pyversion="{}.{}".format(python_version[0], python_version[1]),
153
- ext="egg")
154
-
155
- bdist_egg_log.info("Url: {}".format(url))
156
- egg_data = None
157
- network_error = None
158
- try:
159
- egg_data = urlopen(url).read()
160
- except Exception as e:
161
- network_error = e
162
-
163
-
164
- if network_error is not None:
165
- bdist_egg_log.warn(network_error)
166
- url = url_userpath.format(
167
- platform=os_version,
168
- version=lief_version,
169
- pyversion="{}.{}".format(python_version[0], python_version[1]),
170
- ext="egg")
171
- url = os.path.expanduser(url)
172
- if os.path.isfile(url):
173
- with open(url, 'rb') as f:
174
- egg_data = f.read()
175
- else:
176
- raise Exception("Unable to find {}".format(url))
177
-
178
-
179
- egg_file = BytesIO(egg_data)
180
-
181
- mkpath(os.path.dirname(self.egg_output))
182
-
183
- bdist_egg_log.info("Output: {}".format(self.egg_output))
184
- with open(self.egg_output, 'wb') as f:
185
- f.write(egg_file.getvalue())
186
-
187
- getattr(self.distribution, 'dist_files', []).append(
188
- ('bdist_egg', "{}.{}".format(python_version[0], python_version[1]), self.egg_output))
189
-
190
-
191
-
192
- class lief_build_ext(build_ext):
193
-
194
-
195
- def build_extension(self, ext):
196
- self.target = self.get_ext_fullpath(ext.name)
197
- target_dir = os.path.dirname(self.target)
198
-
199
- try:
200
- os.makedirs(target_dir)
201
- except:
202
- pass
203
-
204
- if in_source_package:
205
- self._install_from_source_package()
206
- else:
207
- shutil.copyfile(libpylief[platform.system()], self.target)
208
-
209
-
210
- def _install_from_source_package(self):
211
- python_version = sys.version_info
212
- python_major_version = python_version[0]
213
- os_version = get_lief_platform_name()
214
- target_extension = os.path.splitext(self.target)[1]
215
-
216
- url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
217
- url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
218
- url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
219
-
220
- url = ""
221
- if is_branch:
222
- url = url_branch_fmt.format(
223
- branch='master',
224
- platform=os_version,
225
- version=lief_version,
226
- pyversion="{}.{}".format(python_version[0], python_version[1]),
227
- ext="egg")
228
- else:
229
- url = url_release_fmt.format(
230
- platform=os_version,
231
- version=lief_version,
232
- pyversion="{}.{}".format(python_version[0], python_version[1]),
233
- ext="egg")
234
-
235
- bdist_egg_log.info("Url: {}".format(url))
236
- egg_data = None
237
- network_error = None
238
- try:
239
- egg_data = urlopen(url).read()
240
- except Exception as e:
241
- network_error = e
242
-
243
- if network_error is not None:
244
- bdist_egg_log.warn(network_error)
245
- url = url_userpath.format(
246
- platform=os_version,
247
- version=lief_version,
248
- pyversion="{}.{}".format(python_version[0], python_version[1]),
249
- ext="egg")
250
- url = os.path.expanduser(url)
251
- if os.path.isfile(url):
252
- with open(url, 'rb') as f:
253
- egg_data = f.read()
254
- else:
255
- raise Exception("Unable to find {}".format(url))
256
-
257
-
258
-
259
-
260
-
261
- egg_file = BytesIO(egg_data)
262
-
263
- egg_zip = zipfile.ZipFile(egg_file)
264
- extension_member = [info for info in egg_zip.infolist() if info.filename.endswith(target_extension)][0]
265
- extension_data = egg_zip.read(extension_member)
266
- with open(self.target, 'wb') as f:
267
- f.write(extension_data)
268
-
269
- setup(
270
- version = lief_version,
271
- ext_modules = [Extension('_pylief', [])],
272
- cmdclass={
273
- 'build_ext': lief_build_ext,
274
- 'bdist_egg': lief_bdist_egg,
275
- 'sdist': lief_sdist
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