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 50+ 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 50+ 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())

📦 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.5.tar.gz (9.8 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.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ahcodecompiler-1.0.5.tar.gz
  • Upload date:
  • Size: 9.8 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.5.tar.gz
Algorithm Hash digest
SHA256 b6ba2e26e65be61f993c8212b33b5c170fdd90c226ad61193c1949dd2ac28a1a
MD5 7a943c004c0d7507559c1fc030218a1d
BLAKE2b-256 40d574cca773c4aafdc0d5d569e0ff2e90f60314630c9a9cf00aa29fe268a2b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ahcodecompiler-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bcf6e2c9823ed1218f801c3546b7b4f53d959bddd8ec81b5238ac2ba1bdf3921
MD5 8fb970cbd1a2774d2bf6822d5c20e1cc
BLAKE2b-256 b5a0c247b0848b5c2e7c5ac051d7d2d1423f1eea9b67b8faa5f9f1cbeba44c68

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