Skip to content

PyChD: The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities

License

Notifications You must be signed in to change notification settings

diohabara/pychd

Repository files navigation

PyChD

CI PyPI Version

The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities

Usage

Install

From pip

pip install pychd

Compile

pychd compile <directory | file> # you need to specify a directory or a .py file

E.g.,

pychd compile examples/01_example_variables.py # `example/__pycache__/01_example_variables.cpython-310.pyc` will be created

Decompile

pychd decompile <pyc-file> # you need to specify a .pyc file

E.g.,

pychd decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompiled code will be printed
pychd decompile example/__pycache__/01_example_variables.cpython-310.pyc -o example/decompiled/01_example_variables.cpython-310.py # decompiled code will be written to `example/decompiled/01_example_variables.cpython-310.py`

Examples

You can find examples in example directory.

Development

Setup

  1. Install rye.

  2. Install all dependencies.

rye sync --all-features
  1. Set OPENAI_API_KEY environment variable. If you're using direnv, you can use .envrc.template as a template.

  2. Run the compiler/decompiler.

Using scripts:

rye run python -m pychd.main compile examples/01_example_variables.py # compile
rye run python -m pychd.main decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompile

Activating the virtual environment:

. .venv/bin/activate
python -m pychd.main compile example/python/01_example_variables.py # compile
python -m pychd.main decompile example/python/01_example_variables.pyc # decompile

About

PyChD: The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities

Topics

Resources

License

Stars

Watchers

Forks