Metadata-Version: 2.4
Name: cexec
Version: 1.1.1
Summary: The C Executor in Python. Compile and run C code in real-time.
Author: Suleiman
License: MIT
Platform: win64
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Software Development :: Compilers
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: platform
Dynamic: requires-python
Dynamic: summary

# cexec — The C Executor in Python

**cexec** is a Python library that allows you to compile and run C code on the fly directly from Python. It supports both standard C compilation (via GCC) and hybrid compilation with NASM for heavy loops, packing them into DLLs for maximum performance.

## ✨ Features

*   **Zero Dependencies**: Uses only the Python standard library.
*   **On-the-fly Execution**: Compile and run C code in a single function call.
*   **GCC & NASM Hybrid**: Uses GCC (C11/C17) for standard code and NASM for heavy loops (Hard-Outlining).
*   **Self-Extracting EXE**: Can build standalone `.exe` files with embedded DLLs loaded via `LoadLibraryA`.
*   **Windows x64 Support**: Optimized for 64-bit Windows systems.

## 🚀 Quick Start

Make sure you have Python 3.8+ installed on **Windows x64** (this package currently supports only Windows x64).

```python
import cexec

c_code = """
#include <stdio.h>

int main() {
    printf("Hello from C Executor!\\n");
    return 0;
}
"""

output = cexec.execute(c_code)
print(output)
```

⚙️ Advanced Usage

1. Hybrid JIT (GCC + NASM)

cexec can automatically find heavy loops and transpile them to NASM, compiling them into a DLL that is loaded dynamically.

```python
import cexec

code = """
#include <stdio.h>

int main() {
    int sum = 0;
    for (int i = 0; i < 1000; i++) {
        sum += i;
    }
    printf("Sum: %d\\n", sum);
    return 0;
}
"""

# use_nasm=True by default
print(cexec.c.execute(code, use_nasm=True))
```

2. Pure NASM Execution

You can also write and execute raw NASM assembly directly:

```python
import cexec

nasm_code = """
global main
extern printf
section .data
    fmt db "Hello from NASM!", 10, 0
section .text
main:
    push rbp
    mov rbp, rsp
    sub rsp, 32
    lea rcx, [rel fmt]
    call printf
    xor eax, eax
    leave
    ret
"""

print(cexec.nasm.execute(nasm_code))
```

⚠️ Important Notes

· Windows Only: This package uses gcc.exe and nasm.exe, which are Windows x64 binaries. It will not work on Linux, macOS, or Android.
· Size: The package is ~32 MB (compressed) because it includes a full GCC compiler and NASM assembler.

📦 Installation

```bash
pip install cexec
```

📄 License

This project is distributed under the MIT License. See the LICENSE file for details.
