Repository navigation
Conversation
install_ida.py never worked: main() was called without arguments, it looked for a nonexistent <IDA_DIR>/venv, and it copied the plugin into the IDA install directory. It now reads the Python library selected with idapyswitch (Python3TargetDLL in ida.reg / the Windows registry / ida-config.json), pip-installs sighthouse.client into the matching interpreter, and copies the plugin into the IDA user plugins directory. Adds --python, --dry-run and --break-system-packages; --ida-dir is now optional. Also: - cli: honour $IDA_DIR / $GHIDRA_INSTALL_DIR, report ValueError cleanly - install_ghidra: don't prompt for (and recreate) the venv twice - Makefile: `make help` now lists install_* targets - docs: explain how IDA picks its Python; fix dead client doc links
Fenrisfulsur
left a comment
There was a problem hiding this comment.
Hi o/
First of all: Thanks a lot for submitting a patch, really appreciate it!
I tested the installer and it work fine. I've left some comments, feel free to discuss.
| | `--dry-run` | Show which interpreter and plugins directory would be used, without changing anything. | | ||
| | `--python PATH` | Use this interpreter instead of the one detected from the `idapyswitch` settings. | | ||
| | `--break-system-packages` | Allow installing into an externally managed Python (PEP 668, e.g. Homebrew or Debian's system Python). Pointing IDA at a non-managed Python with `idapyswitch` is usually a better fix. | | ||
| | `--ida-dir PATH` | IDA installation directory. Optional (also read from `$IDA_DIR`); only used as a sanity check. | |
There was a problem hiding this comment.
We should keep the option for users to force the ida directory if they really want (so remove 'only used as a sanity check')
|
|
||
| from sighthouse.client.install_binja import main as binja_main | ||
| from sighthouse.client.install_ida import main as ida_main | ||
| from sighthouse.client.install_ida import InstallError, main as ida_main |
There was a problem hiding this comment.
InstallError could be a generic exception raised by all the installers. It should be moved to a file like installer.py or something like this.
| # Setup variables | ||
| install_dir = Path(install_dir) | ||
| python_cmd: str = sys.executable | ||
| python_cmd: str | None = sys.executable |
There was a problem hiding this comment.
Are there cases where sys.executable could be None ? If that the case, maybe add a comment explaining why.
| REGISTRY_KEY = "Python3TargetDLL" | ||
|
|
||
|
|
||
| class InstallError(Exception): |
There was a problem hiding this comment.
InstallError could be a generic exception raised by all the installers. It should be moved to a file like installer.py or something like this.
| return candidates | ||
|
|
||
|
|
||
| def _interpreter_version(python: Path) -> str | None: |
There was a problem hiding this comment.
This method could be useful for all installers (need to be made public). It should be moved to a file like installer.py or something like this.
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def _is_externally_managed(python: Path) -> bool: |
There was a problem hiding this comment.
This method kinda already exists in install_ghidra.py but your version is better I think. It could be useful for all installers (need to be made public). It should be moved to a file like installer.py or something like this. Then we should remove both definition from install_ghidra/ida files.
| if ida_dir is not None and not Path(ida_dir).expanduser().exists(): | ||
| raise InstallError(f"IDA directory not found: {ida_dir}") | ||
|
|
||
| user_dir = get_ida_user_dir() |
There was a problem hiding this comment.
We should let the user force the ida directory if he really want. I propose:
user_dir = ida_dir or get_ida_user_dir()| ] | ||
| subprocess.check_call([python_cmd] + pip_args_sighthouse) | ||
| copy_client_script_to_idadir(install_dir) | ||
| def add_arguments(parser: ArgumentParser) -> None: |
There was a problem hiding this comment.
This has no other use, we can inline it in main
|
|
||
| def install_package(python: Path, break_system_packages: bool, dry_run: bool) -> None: | ||
| cmd = [str(python), "-m", "pip", "install", "--upgrade", PACKAGE] | ||
| if _is_externally_managed(python): |
There was a problem hiding this comment.
I think we should check whether we are in a virtual environment or not because is_externally_managed() will return True even if we are inside a venv but the installation will not need --break-system-packages.
The is_venv method should be updated and moved into the shared installer.py:
def is_venv(python: Path) -> bool:
"""Return whether the given python installation is a Virtual Environment."""
out = subprocess.run(
[str(python), "-I", "-c", "import sys;print(sys.prefix!=sys.base_prefix)"],
capture_output=True, text=True,
).stdout.strip()
return out == "True"
install_ida.py never worked: main() was called without arguments, it looked for a nonexistent <IDA_DIR>/venv, and it copied the plugin into the IDA install directory.
It now reads the Python library selected with idapyswitch (Python3TargetDLL in ida.reg / the Windows registry / ida-config.json), pip-installs sighthouse.client into the matching interpreter, and copies the plugin into the IDA user plugins directory. Adds --python, --dry-run and --break-system-packages; --ida-dir is now optional.
Also:
make helpnow lists install_* targets