pycdc icon indicating copy to clipboard operation
pycdc copied to clipboard

Python bindings & package

Open percevalw opened this issue 1 year ago • 3 comments

Hi,

Thanks for this tool, I've been finding myself needing to recover functions from Python __code__ objects. To facilitate / speed up this step, I propose this PR, which adds Python bindings to allow using pycdc on marshaled objects from Python directly.

The key changes are the following:

  • Addition of Python bindings using pybind11.
  • A new Python package pycdc, enabling users to pip install ..
  • Additional dedicated CMake file, to keep changes to the codebase minimal.
  • Conversion of C style IO to C++ streams, to enable output redirection to Python.
  • Necessary Python build files like setup.py, pyproject.toml

I've tried to keep changes to the codebase and requirements to a minimum. Please let me know if there are any improvements needed.

I've not added Github actions at this point but having the package on PyPi would be great. I can add them if the above changes work for you.

percevalw avatar Jun 01 '23 23:06 percevalw

Additionally, this would solve https://github.com/zrax/pycdc/issues/192

percevalw avatar Jun 05 '23 08:06 percevalw

This sounds like a neat feature... In order to make it easier to review, I merged the first part (using C++ iostreams) separately, since that has other benefits as well and doesn't appear to impact performance much. Can you rebase this on the latest master when you get a chance?

zrax avatar Jun 05 '23 21:06 zrax

Thank you for you efforts ! I've rebased and added an option for decompyling non-marshaled outputs (decompyle(..., version=None), similar to no -c -v ...)

percevalw avatar Jun 05 '23 21:06 percevalw