Skip to main content

A powerful Python SDK and interactive CLI editor by Akash Halder for compiling and executing code with rich terminal output and supports for 30+ programming languages.

Project description

ah_code_compiler_banner_img

Python Version Website

A lightweight Python SDK to compile and execute code using a powerful code-execution API. Perfect for building online code editors, testing environments, and educational platforms.

A Python port of the original TypeScript SDK

🎯 Try the live demo here: https://www.akashhalder.in/code-compiler


✨ Features

  • Fetch supported runtimes with versions
  • Execute code in 30+ programming languages
  • Beautiful CLI output
  • Intelligent error and warning formatting
  • Easy-to-use abstraction via AHCodeCompiler class
  • Built-in compiler.help() method for usage reference
  • Bonus: Comes with a ready-to-use CLI code editor (editor.start())

💡CLI Editor Demo


📦 Installation

pip install ahcodecompiler

# In Jupyter notebook / lab or Google Collab
!pip install ahcodecompiler

🚀 Usage (Python)

from AHCodeCompiler import AHCodeCompiler

compiler = AHCodeCompiler()

# Get all Runtimes
compiler.get_runtimes()

# Execute Code via this method
compiler.execute(
    language="javascript",
    files=[
        {
            "name": "main.js", 
            "content": "console.log('🔥 Hello!')"
        }
    ]
)

# Get usage help
compiler.help()

🖥️ Interactive CLI Code Editor

This SDK ships with an ready to use CLI-based code editor and runner which internally uses the same AHCodeCompiler class.

Usage:

from AHCodeCompiler import Editor

Editor.start()

What It Does??

  • Prompts user to select a language
  • Loads available runtimes from the API
  • Accepts multiline code input
  • Automatically detects appropriate filename
  • Displays output and error in styled CLI format

📚 API Reference

class AHCodeCompiler

Main SDK wrapper for all functionality.

get_runtimes() -> List[Dict]

Fetch all supported runtimes (languages + versions).

execute(language: str, version: str = None, files: List[Dict[str, str]]) -> Dict

Execute code using the given language, version, and files.

Auto-detects version if not provided.

compiler.execute(
    language="python",
    files=[{"name": "main.py", "content": "print('Hello World')"}]
)

help()

Print a beautiful CLI-style usage guide right in your terminal.

🧪 Advanced CLI Output

  • ✅ Success Panels (Green)
  • ⚠️ Stderr Panels (Yellow/Red with colorized error/warning lines)
  • ⛔ Error Panels (if execution fails)

🌍 Supported Languages

Some popular languages include:

  • Python (python3)
  • JavaScript (node)
  • C++
  • Java
  • Go
  • Rust
  • TypeScript
  • C#
  • Ruby
  • PHP
  • ...and many more!

Use compiler.get_runtimes() to fetch the full, up-to-date list.


🧠 Why Use This?

  • Makes building compilers, online editors, judge systems easy
  • Just plug & play, no complex setup
  • Clean abstraction for both beginners & advanced devs
  • Same SDK is available in TypeScript

📄 License

MIT License © Akash Halder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ahcodecompiler-1.0.6.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ahcodecompiler-1.0.6-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file ahcodecompiler-1.0.6.tar.gz.

File metadata

  • Download URL: ahcodecompiler-1.0.6.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ahcodecompiler-1.0.6.tar.gz
Algorithm Hash digest
SHA256 140675143c12e860f85d341aa2a115a23bd6814bbdef4854eca6388c2e941575
MD5 7fa24791caf593e175bd18b464899f34
BLAKE2b-256 9d5a1988d1fe00caf947f8c49857d7a4b8ea8546fa6adcaf917465d1023a34b3

See more details on using hashes here.

File details

Details for the file ahcodecompiler-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: ahcodecompiler-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ahcodecompiler-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9a44de3cb93a388a658655872eb51276eda4dac90ba5b3263549b2b50123bd75
MD5 f8dce1ed67be11c7ff6bbc095a829df6
BLAKE2b-256 c498fa16f92ab1afa927b4dd32daefbf8a73726cb45ddb08e7dbd5d46735703d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page