Skip to main content

A Python library to run code from multiple programming languages.

Project description

Intro

CrossLang is a Python library that allows developers to run code written in various programming languages directly from their Python scripts. This can be particularly useful for multi-language projects, testing, and automation.

Supports multiple programming languages including Rust, C, Java, Ruby, Lua, Go, JavaScript, PHP, Perl, Scala, Shell, Swift, Kotlin, and Haskell. Automatically compiles and runs code snippets. Easy to integrate into existing Python projects.

Installation

To install CrossLang, you can use pip:

pip install python-crosslang

Installing Compilers and Interpreters

CrossLang relies on various external compilers and interpreters to execute code in different languages. You can use the provided installation scripts to set up the necessary dependencies.

For Unix-based Systems (Linux/macOS): Run the following script to install the required compilers and interpreters:

chmod +x debian.sh; ./debian.sh

For Arch Linux:
Run the following script to install the required compilers and interpreters:

chmod +x arch.sh; ./arch.sh

For Windows:
Run the following PowerShell script to install the required compilers and interpreters:

.\windows.ps1

Usage

Here's an example of how to use CrossLang in your Python script:

from CrossLang import Translator

# Running Rust code
code = """
fn main() {
    println!("Hello, world!");
}
"""

output = Translator('rust', code)
print(output)

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

int main() {
    printf("Hello, World!\\n");
    return 0;
}
"""

output = Translator('c', code)
print(output)

# Running Java code
code = """
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
"""

output = Translator('java', code)
print(output)

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

python_crosslang-0.1.4.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

python_crosslang-0.1.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file python_crosslang-0.1.4.tar.gz.

File metadata

  • Download URL: python_crosslang-0.1.4.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for python_crosslang-0.1.4.tar.gz
Algorithm Hash digest
SHA256 bc6cd8c5c354ba80ff4940d51337eda6cb3069e4bdab6d6aa7cc6f667ac43a85
MD5 fea8b55a5a813664dd0d90c896b2f218
BLAKE2b-256 d56603c1b40367617359817e0af9c87ec9170052a72e7219e64b700ad4e8d5db

See more details on using hashes here.

File details

Details for the file python_crosslang-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for python_crosslang-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f8515962ab8468fe995859c37e1e44aac13ad75368086b3d1f340f9e837d95bc
MD5 c23e1508735a31a36287f66fd49aed32
BLAKE2b-256 7111e8622edaffad99295969ff04e91a586b40e3d2e06b97280f6bcaeb713299

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