-
Notifications
You must be signed in to change notification settings - Fork 30
/
setup.py
81 lines (66 loc) · 2.42 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
import logging
import os
import subprocess
from setuptools import find_packages, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.develop import develop
from setuptools.command.install import install
from strongarm import __url__, __version__
from strongarm.logger import strongarm_logger
logger = strongarm_logger.getChild(__file__)
def install_capstone() -> None:
platform = getattr(os.uname(), "sysname", None)
logger.info(f"Installing Capstone for platform: {platform}")
if platform == "Darwin":
logger.info("Installing Capstone backend from brew...")
subprocess.run(["brew", "install", "[email protected]"])
elif platform == "Linux":
logger.info("Installing Capstone backend from apt-get...")
subprocess.run(["apt-get", "update"])
subprocess.run(
[
"apt-get",
"install",
"libcapstone4=4.0.2-5",
"libcapstone-dev=4.0.2-5",
"sqlite3",
"libsqlite3-dev",
"-y",
"--allow-unauthenticated",
]
)
else:
# Let's not make this a fatal error, as the user may be able to install Capstone on their own
logger.warning(f"Unknown platform: {platform}")
logger.warning("You must install the capstone backend before using strongarm")
# https://stackoverflow.com/questions/19569557/pip-not-picking-up-a-custom-install-cmdclass
class InstallCapstoneBuildExtCmd(build_ext):
def run(self) -> None:
install_capstone()
super().run()
class InstallCapstoneInstallCmd(install):
def run(self) -> None:
install_capstone()
super().run()
class InstallCapstoneDevelopCmd(develop):
def run(self) -> None:
install_capstone()
super().run()
# Ensure our logs when installing Capstone show up
logging.basicConfig(level=logging.INFO)
setup(
name="strongarm-ios",
version=__version__,
description="Mach-O/ARM64 analyzer",
author="Data Theorem",
url=__url__,
packages=find_packages(exclude=["tests"]),
install_requires=["capstone==4.0.2", "more_itertools", "strongarm_dataflow==3.0.0"],
package_data={"strongarm": ["py.typed"]},
data_files=[("", ["LICENSE.txt"])],
cmdclass={
"build_ext": InstallCapstoneBuildExtCmd,
"install": InstallCapstoneInstallCmd,
"develop": InstallCapstoneDevelopCmd,
},
)