Skip to content

Commit

Permalink
setup: Fix installation of agents
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed May 18, 2024
1 parent 947fc55 commit fd37e42
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

SOURCE_ROOT = Path(__file__).resolve().parent

pkg_info = SOURCE_ROOT / "PKG-INFO"
in_source_package = pkg_info.exists()


def main():
setup(
Expand Down Expand Up @@ -51,7 +54,7 @@ def main():
],
packages=["frida_tools"],
package_data={
"frida_tools": copy_in_built_agents(),
"frida_tools": fetch_built_agents(),
},
entry_points={
"console_scripts": [
Expand All @@ -76,8 +79,6 @@ def main():


def detect_version() -> str:
pkg_info = SOURCE_ROOT / "PKG-INFO"
in_source_package = pkg_info.exists()
if in_source_package:
version_line = [
line for line in pkg_info.read_text(encoding="utf-8").split("\n") if line.startswith("Version: ")
Expand All @@ -95,15 +96,18 @@ def detect_version() -> str:
return version


def copy_in_built_agents() -> list[str]:
def fetch_built_agents() -> list[str]:
agents = []
agents_builddir = SOURCE_ROOT / "build" / "agents"
if agents_builddir.exists():
for child in agents_builddir.iterdir():
if child.is_dir():
for f in child.glob("*_agent.js"):
shutil.copy(f, SOURCE_ROOT / "frida_tools")
agents.append(f.name)
if in_source_package:
agents += [f.name for f in (SOURCE_ROOT / "frida_tools").glob("*_agent.js")]
else:
agents_builddir = SOURCE_ROOT / "build" / "agents"
if agents_builddir.exists():
for child in agents_builddir.iterdir():
if child.is_dir():
for f in child.glob("*_agent.js"):
shutil.copy(f, SOURCE_ROOT / "frida_tools")
agents.append(f.name)
return agents


Expand Down

0 comments on commit fd37e42

Please sign in to comment.