forked from erocarrera/pefile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·101 lines (78 loc) · 2.63 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
#!/usr/bin/python
import ast
import os
import re
import sys
from io import open
try:
from setuptools import setup, Command
except ImportError as excp:
from distutils.core import setup, Command
from unittest import TestLoader, TextTestRunner
os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
os.environ['COPYFILE_DISABLE'] = 'true'
def _read_doc():
"""
Parse docstring from file 'pefile.py' and avoid importing
this module directly.
"""
with open('pefile.py', 'r', encoding='utf-8') as f:
tree = ast.parse(f.read().encode('ascii', 'backslashreplace'))
return ast.get_docstring(tree)
def _read_attr(attr_name):
"""
Parse attribute from file 'pefile.py' and avoid importing
this module directly.
__version__, __author__, __contact__,
"""
regex = attr_name + r"\s+=\s+'(.+)'"
with open('pefile.py', 'r', encoding='utf-8') as f:
match = re.search(regex, f.read())
# Second item in the group is the value of attribute.
return match.group(1)
class TestCommand(Command):
"""Run tests."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
# build_msi does not support the 1.2.10-139 versioning schema
# (or 1.2.10.139), hence the revision number is stripped.
pefile_version = _read_attr('__version__')
if 'bdist_msi' in sys.argv:
pefile_version, _, _ = pefile_version.partition('-')
class TestCommand(Command):
"""Run tests."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
test_suite = TestLoader().discover('./tests', pattern='*_test.py')
test_results = TextTestRunner(verbosity=2).run(test_suite)
setup(name = 'pefile',
version = pefile_version,
description = 'Python PE parsing module',
author = _read_attr('__author__'),
author_email = _read_attr('__contact__'),
url = 'https://github.com/erocarrera/pefile',
download_url='https://github.com/erocarrera/pefile/files/192316/pefile-2016.3.28.tar.gz',
keywords = ['pe', 'exe', 'dll', 'pefile', 'pecoff'],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'],
long_description = "\n".join(_read_doc().split('\n')),
cmdclass={"test": TestCommand},
py_modules = ['pefile', 'peutils'],
packages = ['ordlookup'],
install_requires=[
'future',
],
)