evgenyigumnov / rustsn

This Rust-based tool generates, compiles, and tests code using LLMs, resolves dependencies, and provides explanations of existing code through embeddings.
Apache License 2.0
60 stars 15 forks source link

Add Python support #4

Closed evgenyigumnov closed 1 month ago

evgenyigumnov commented 1 month ago
  1. Create Folder

    Create a folder named python.

  2. Copy Files

    Create copies of prompt.txt inside the python folder.


Launch Example

rustsn --lang=python

Example Query

take 2 params and add them and return result

Example Generation

setup.py

from setuptools import setup, find_packages

setup(
    name="solution",
    version="1.0.0",
    description="Minimalistic project",
    packages=find_packages(where='src'),
    package_dir={"": "src"},
    install_requires=[],
    tests_require=["pytest"],
    entry_points={
        "console_scripts": [
            "solution=src.solution:main",
        ],
    },
)

requirements.txt

pytest

src/solution.py

def solution(a, b):
    return a + b

tests/test_solution.py

import pytest
from src.solution import solution

def test_solution_integers():
    assert solution(1, 2) == 3

def test_solution_negatives():
    assert solution(-1, -2) == -3

def test_solution_strings():
    assert solution('1', '2') == '12'

Example Install Dependencies

pip install -r requirements.txt

Example Launch Compilation

Python typically doesn't require a compilation step, but if you are packaging the project, you can build it using:

python setup.py build

Example Launch Test

Run the tests using pytest:

pytest