From ec854c9308f6d67af22b63d238b1ceafa559673d Mon Sep 17 00:00:00 2001 From: MS Date: Sat, 16 Dec 2023 05:59:17 -0500 Subject: [PATCH] Move redist tools to central location (#334) * Move redist tools to central location * Include exe and dll in package setup --- .../isledecomp/lib}/DUMPBIN.EXE | Bin .../{verexp => isledecomp/isledecomp/lib}/LINK.EXE | Bin .../isledecomp/lib}/MSPDB41.DLL | Bin tools/isledecomp/isledecomp/lib/__init__.py | 13 +++++++++++++ .../isledecomp/lib}/cvdump.exe | Bin tools/isledecomp/isledecomp/syminfo.py | 4 ++-- tools/isledecomp/setup.py | 2 ++ tools/verexp/verexp.py | 7 ++----- 8 files changed, 19 insertions(+), 7 deletions(-) rename tools/{verexp => isledecomp/isledecomp/lib}/DUMPBIN.EXE (100%) rename tools/{verexp => isledecomp/isledecomp/lib}/LINK.EXE (100%) rename tools/{verexp => isledecomp/isledecomp/lib}/MSPDB41.DLL (100%) create mode 100644 tools/isledecomp/isledecomp/lib/__init__.py rename tools/{reccmp => isledecomp/isledecomp/lib}/cvdump.exe (100%) diff --git a/tools/verexp/DUMPBIN.EXE b/tools/isledecomp/isledecomp/lib/DUMPBIN.EXE similarity index 100% rename from tools/verexp/DUMPBIN.EXE rename to tools/isledecomp/isledecomp/lib/DUMPBIN.EXE diff --git a/tools/verexp/LINK.EXE b/tools/isledecomp/isledecomp/lib/LINK.EXE similarity index 100% rename from tools/verexp/LINK.EXE rename to tools/isledecomp/isledecomp/lib/LINK.EXE diff --git a/tools/verexp/MSPDB41.DLL b/tools/isledecomp/isledecomp/lib/MSPDB41.DLL similarity index 100% rename from tools/verexp/MSPDB41.DLL rename to tools/isledecomp/isledecomp/lib/MSPDB41.DLL diff --git a/tools/isledecomp/isledecomp/lib/__init__.py b/tools/isledecomp/isledecomp/lib/__init__.py new file mode 100644 index 00000000..f1081a81 --- /dev/null +++ b/tools/isledecomp/isledecomp/lib/__init__.py @@ -0,0 +1,13 @@ +"""Provides a reference point for redistributed tools found in this directory. +This allows you to get the path for these tools from a script run anywhere.""" +from os.path import join, dirname + + +def lib_path() -> str: + """Returns the directory for this module.""" + return dirname(__file__) + + +def lib_path_join(name: str) -> str: + """Convenience wrapper for os.path.join.""" + return join(lib_path(), name) diff --git a/tools/reccmp/cvdump.exe b/tools/isledecomp/isledecomp/lib/cvdump.exe similarity index 100% rename from tools/reccmp/cvdump.exe rename to tools/isledecomp/isledecomp/lib/cvdump.exe diff --git a/tools/isledecomp/isledecomp/syminfo.py b/tools/isledecomp/isledecomp/syminfo.py index 6a26e30f..3e98c118 100644 --- a/tools/isledecomp/isledecomp/syminfo.py +++ b/tools/isledecomp/isledecomp/syminfo.py @@ -1,6 +1,6 @@ import os import subprocess -from .utils import get_file_in_script_dir +from isledecomp.lib import lib_path_join class RecompiledInfo: @@ -18,7 +18,7 @@ class SymInfo: def __init__(self, pdb, sym_recompfile, sym_logger, sym_wine_path_converter=None): self.logger = sym_logger - call = [get_file_in_script_dir("cvdump.exe"), "-l", "-s"] + call = [lib_path_join("cvdump.exe"), "-l", "-s"] if sym_wine_path_converter: # Run cvdump through wine and convert path to Windows-friendly wine path diff --git a/tools/isledecomp/setup.py b/tools/isledecomp/setup.py index 1e3c0863..bf3e05dc 100644 --- a/tools/isledecomp/setup.py +++ b/tools/isledecomp/setup.py @@ -6,4 +6,6 @@ description="Python tools for the isledecomp project", packages=find_packages(), tests_require=["pytest"], + include_package_data=True, + package_data={"isledecomp.lib": ["*.exe", "*.dll"]}, ) diff --git a/tools/verexp/verexp.py b/tools/verexp/verexp.py index 455791e1..e112c07a 100755 --- a/tools/verexp/verexp.py +++ b/tools/verexp/verexp.py @@ -4,8 +4,8 @@ import difflib import subprocess import os -import sys +from isledecomp.lib import lib_path_join from isledecomp.utils import print_diff @@ -32,11 +32,8 @@ def main(): if not os.path.isfile(args.recompiled): parser.error(f"Recompiled binary {args.recompiled} does not exist") - def get_file_in_script_dir(fn): - return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn) - def get_exports(file): - call = [get_file_in_script_dir("DUMPBIN.EXE"), "/EXPORTS"] + call = [lib_path_join("DUMPBIN.EXE"), "/EXPORTS"] if os.name != "nt": call.insert(0, "wine")