Skip to content
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

Python bindings & package #349

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

percevalw
Copy link
Contributor

@percevalw percevalw commented Jun 1, 2023

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
Copy link
Contributor Author

Additionally, this would solve #192

@zrax
Copy link
Owner

zrax commented Jun 5, 2023

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?

@percevalw percevalw force-pushed the python-bindings branch 2 times, most recently from baf144b to d766ee0 Compare June 5, 2023 21:48
@percevalw
Copy link
Contributor Author

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 ...)

.gitignore Outdated Show resolved Hide resolved
pyc_module.cpp Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants