Giter VIP home page Giter VIP logo

jedirhymetrix / pycrust Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 3.0 6 KB

PyCrust is a CLI tool that converts Python code to Rust using OpenAI's GPT-3.5 language model for code generation. It provides an easy-to-use interface for converting Python code to Rust code, making it easier for Python developers to leverage Rust's performance benefits.

Dockerfile 18.10% Shell 17.29% Python 64.61%
conversion python rust rust-lang chatgpt chatgpt-api cli-tool code-generation docker gpt

pycrust's Introduction

PyCrust ๐Ÿฅง [WIP] ๐Ÿšง

Pie-crust / Py(c)Rust

PyCrust is a command-line tool that transpiles Python code to Rust code, replacing Python libraries with equivalent Rust libraries wherever possible. It uses the OpenAI ChatGPT API to perform the transpilation.

Usage ๐Ÿš€

  1. Install Docker and Docker Compose
  2. Clone this repository: git clone https://github.com/JediRhymeTrix/pycrust.git
  3. cd pycrust
  4. Create a .env file with your ChatGPT API key: echo "API_KEY=<your-api-key>" > .env
  5. Give the runner shell script the appropriate permission to run: chmod +x scripts/pycrust.sh
  6. Run the Docker container and transpile your code using the command ./pycrust.sh /path/to/input.py to transpile the Python code to Rust code. The output will be saved in a file with the same name as the input file, but with the .rs extension.

Dependencies ๐Ÿ“ฆ

  • Docker
  • Docker Compose
  • OpenAI ChatGPT API key

Directory Structure ๐Ÿ“

pycrust/
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ download_dependencies.sh
โ”‚   โ””โ”€โ”€ pycrust.sh
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ pycrust.py
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_pycrust.py
โ””โ”€โ”€ requirements.txt

Notes ๐Ÿ“

  • This tool is still in development and may not work with all Python code.
  • The Rust code generated by PyCrust may require additional work to compile and run.
  • If a Rust equivalent library for a Python library does not exist, PyCrust will generate a list of missing dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.