Skip to main content

A Python SDK for code compilation by Akash Halder. It allows developers to use this SDK and create their frontend for online code compilation

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
  • Built-in error/output handling
  • Easy to plug into any Python backend or CLI tool

📦 Installation

pip install ah-code-compiler-sdk

🚀 Usage (Python)

import AHCodeCompiler.compiler as compiler

# Get all run-time Environment
runtimes = compiler.get_runtimes()
print("Available Runtimes: \n", runtimes)

# Execute Code of the Supported Language
result = compiler.execute_code(
    language="javascript",
    version="18.15.0",
    files=[
        {
            "name": "main.js",
            "content": "console.log('Hello from JavaScript!');"
        }
    ]
)

# Extract output and error
stdout = result.get('run', {}).get('stdout')
stderr = result.get('run', {}).get('stderr')

# Conditional rendering
if stdout:
    print("✅ Output:")
    print(stdout.strip())
elif stderr:
    print("❌ Error:")
    print(stderr.strip())
else:
    print("⚠️ No output or error received.")

📚 API Reference

class AHCodeCompiler

Main SDK wrapper for all functionality.

get_runtimes() -> list[dict]

Fetch all supported runtimes.

Returns:

[
  {
    "language": "python3",
    "version": "3.10.0",
    "aliases": ["py", "py3"],
    "runtime": "python"
  },
  ...
]

execute_code(language: str, version: str, files: list[dict]) -> dict

Execute code for the given language and version.

Example:

compiler.execute_code(
    language="python3",
    version="3.10.0",
    files=[
        {"name": "main.py", "content": "print('Hello World')"}
    ]
)

🌍 Supported Languages

Some of the popular languages supported:

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

Use get_runtimes() to fetch the latest list.

📄 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.1.tar.gz (4.3 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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ahcodecompiler-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 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.1.tar.gz
Algorithm Hash digest
SHA256 2711853017a1e9f5243327e4693887b7c01d886fba9d764c39f40d94889daff5
MD5 3af54ed5b4aca692f6df9e42b2937615
BLAKE2b-256 3de383e3e7570b0052c49fc9a8d647665b9bbf1893af3e83f2c58872442899ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ahcodecompiler-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a28e571437d7424b3bd582aa260e6a2a2ae04dcbdd34b002bf65247dea805fb
MD5 59e2c34e2a9fe1366242f1ab38b30a25
BLAKE2b-256 8f4ab00b6757df67f5053e7997b58584867e1f333ea6241b1d913daa60542d3d

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