-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configure Ghidrathon using absolute path of Python interpreter used to install Jep #85
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We passing CI tests across:
🥳 Also, we need to squash and merge this 🤣 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR narrows Ghidrathon's installation steps to:
pip install jep==4.2
python ghidrathon_configure.py <absolute_path_to_ghidra_install>
using the Python interpreter that you'd like to configure for Ghidrathon (ghidrathon_configure.py)ghidra_11.0_PUBLIC_20240125_Ghidrathon.zip for beta example) and install to Ghidra
This PR borrows concepts from #50 but takes a different path to configuring Jep for the following reasons:
We cannot rely on per session environment variables, e.g.
VIRTUAL_ENV
, to be available when Ghidrathon's code is executed. For example,VIRTUAL_ENV
works fine in Linux but is lost on Windows making it difficult to detect when a virtual environment is being used. This also complicates our ability to dynamically resolve where the correct Python andJep
are installed.The Python
sys
module must be specially configured becauseJep
uses an embedded Python interpreter, not the interpreter that was used to install it. Specifically, we must set the following correctly:sys.prefix
sys.base_prefix
sys.exec_prefix
sys.base_exec_prefix
sys.executable
sys._base_executable
The
site
module setssys.base_/prefix
andsys.base_/exec_prefix
differently if a virtual environment is being used. Specifically, thesite
module checks if the parent directory ofsys.executable
contains a file namedpyenv.cfg
w/out relying onVIRTUAL_ENV
being set. Therefore, if we manually setsys._base_/executable
to the absolute path of the Python interpreter used to installJep
then thesite
module can be invoked manually to properly configure thesys
module with no further intervention on our part, including Python virtual environments. For this to work, we must follow the correct ordering to avoid a chicken and egg problem:jep.MainInterpreter
to use the correctJep
native library path, add theJep
Python package path tosys.path
, and disable auto importing thesite
modulejep.SubInterpreter
sys._base_/executable
to the absolute path of the Python interpreter used to installJep
site
module and executesite.main()
sys.path
to include Ghidrathon-specific Python pathsWe may be able to avoid these steps using
Py_SetProgramName
beforePy_Initialize
is called butJep
does not currently support this. I've opened a new issue upstream to request this.Until
Jep
enables more fine-grained control over the embedded Python interpreter's configuration I believe our least path to resistance requires that Ghidrathon know the absolute path of the Python interpreter used to install Jep.TODO:
Jep
version is as expected (should match what we use to build release)closes #1, #3, #8, #27, #34, #49, #62, #78, #81
supersedes #4, #46, #50, #63