Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diohabara/pychd
PyChD: The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities
https://github.com/diohabara/pychd
chatgpt-api decompiler python
Last synced: 23 days ago
JSON representation
PyChD: The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities
- Host: GitHub
- URL: https://github.com/diohabara/pychd
- Owner: diohabara
- License: mit
- Created: 2023-04-19T04:59:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-23T13:41:26.000Z (6 months ago)
- Last Synced: 2024-11-08T13:46:30.754Z (about 2 months ago)
- Topics: chatgpt-api, decompiler, python
- Language: Python
- Homepage:
- Size: 204 KB
- Stars: 33
- Watchers: 2
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyChD
[![CI](https://github.com/diohabara/pychd/actions/workflows/ci.yml/badge.svg)](https://github.com/diohabara/pychd/actions/workflows/ci.yml)
[![PyPI Version](https://img.shields.io/pypi/v/pychd.svg)](https://pypi.python.org/pypi/pychd)The ChatGPT-powered decompiler for Python, providing superior code analysis capabilities
## Usage
### Install
From pip
```bash
pip install pychd
```### Compile
```bash
pychd compile # you need to specify a directory or a .py file
```E.g.,
```bash
pychd compile examples/01_example_variables.py # `example/__pycache__/01_example_variables.cpython-310.pyc` will be created
```### Decompile
```bash
pychd decompile # you need to specify a .pyc file
```E.g.,
```bash
pychd decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompiled code will be printed
``````bash
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](https://rye.astral.sh/guide/installation/).
2. Install all dependencies.
```bash
rye sync --all-features
```3. Set `OPENAI_API_KEY` environment variable. If you're using `direnv`, you can use `.envrc.template` as a template.
4. Run the compiler/decompiler.
Using scripts:
```bash
rye run python -m pychd.main compile examples/01_example_variables.py # compile
``````bash
rye run python -m pychd.main decompile example/__pycache__/01_example_variables.cpython-310.pyc # decompile
```Activating the virtual environment:
```bash
. .venv/bin/activate
``````bash
python -m pychd.main compile example/python/01_example_variables.py # compile
``````bash
python -m pychd.main decompile example/python/01_example_variables.pyc # decompile
```