-
Notifications
You must be signed in to change notification settings - Fork 46
/
setup.py
138 lines (126 loc) · 4.56 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
import os
import platform
import re
import sys
from typing import Optional, Tuple
from setuptools import find_packages, setup
PYTHON_REQUIRES = ">=3.7"
if sys.platform == "darwin":
try:
macos_major_version = int(platform.release().split(".")[0])
if macos_major_version >= 20:
# We are running macOS Big Sur or later.
# The new shared cache on Big Sur breaks `ctypes.util.find_library`,
# which is used by the `cxxfilt` dependency.
# https://stackoverflow.com/questions/62587131/macos-big-sur-python-ctypes-find-library-does-not-find-libraries-ssl-corefou/63609524#63609524
# https://github.com/python/cpython/pull/22855
# This wasn't patched in CPython until version 3.9.1, so require that:
PYTHON_REQUIRES = ">=3.9.1"
except ValueError:
pass
SETUP_DIR = os.path.dirname(os.path.realpath(__file__))
POLYTRACKER_HEADER = os.path.join(
SETUP_DIR, "polytracker", "include", "polytracker", "polytracker.h"
)
README_PATH = os.path.join(SETUP_DIR, "README.md")
if not os.path.exists(POLYTRACKER_HEADER):
sys.stderr.write(
f"Error loading polytracker.h!\nIt was expected to be here:\n{POLYTRACKER_HEADER}\n\n"
)
exit(1)
def polytracker_version() -> Tuple[int, int, int, Optional[str]]:
version_parts = {}
with open(POLYTRACKER_HEADER, "r") as f:
for i, line in enumerate(f):
m = re.match(
r"\s*#define\s+POLYTRACKER_VERSION_([A-Za-z_0-9]+)\s+([^\s]+)\s*$", line
)
if m:
if m[1] not in ("MAJOR", "MINOR", "REVISION", "SUFFIX"):
sys.stderr.write(
f'Warning: Ignoring unexpected #define for "POLYTRACKER_VERSION_{m[1]}" on line '
f"{i + 1} of {POLYTRACKER_HEADER}\n"
)
else:
version_parts[m[1]] = m[2]
for required_part in ("MAJOR", "MINOR", "REVISION"):
if required_part not in version_parts:
sys.stderr.write(
f"Error: #define POLYTRACKER_VERSION_{required_part} not found in {POLYTRACKER_HEADER}\n\n"
)
sys.exit(1)
try:
version_parts[required_part] = int(version_parts[required_part])
except ValueError:
sys.stderr.write(
f"Error: POLYTRACKER_VERSION_{required_part} in {POLYTRACKER_HEADER} is not an integer!\n\n"
)
sys.exit(1)
suffix = version_parts.get("SUFFIX", None)
if suffix is not None:
suffix = suffix.strip()
if suffix.startswith('"') and suffix.endswith('"'):
suffix = suffix[1:-1]
return (
version_parts["MAJOR"],
version_parts["MINOR"],
version_parts["REVISION"],
suffix,
)
def polytracker_version_string() -> str:
*primary, suffix = polytracker_version()
primary = map(str, primary)
if suffix is None:
return ".".join(primary)
else:
return f"{'.'.join(primary)}{suffix}"
CONSOLE_SCRIPTS = [
"polytracker = polytracker.__main__:main",
]
with open(README_PATH, "r") as readme:
README = readme.read()
setup(
name="polytracker",
description="An LLVM-based instrumentation tool for universal taint tracking, dataflow analysis, and tracing.",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/trailofbits/polytracker",
author="Trail of Bits",
version=polytracker_version_string(),
packages=find_packages(),
python_requires=PYTHON_REQUIRES,
install_requires=[
"blight~=0.0.47",
"cxxfilt~=0.2.2",
"docker~=4.4.0",
"graphviz~=0.14.1",
"intervaltree~=3.0.2",
"networkx~=2.4",
"Pillow>=7.2.0",
"prompt_toolkit~=3.0.8",
"pygments~=2.15.0",
"tqdm>=4.59.0", # We need at least this version to get the `delay` option
"typing_extensions>=3.7.4.2",
"types-setuptools~=57.4.9",
],
extras_require={
"dev": [
"black>=22.3.0",
"mypy",
"pytest",
"flake8",
"Sphinx",
"sphinx_rtd_theme>=0.6",
"types-setuptools",
]
},
entry_points={"console_scripts": CONSOLE_SCRIPTS},
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Utilities",
],
)