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

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_crosslang-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 0a714448fcbcaa4b2034dc832db5214817825c53cf7cd57eba2fca11e87fba87
MD5 c85c06df08ae6fbc5d0520be78a1790f
BLAKE2b-256 71f9af110f0a826f99c216320501970d52eb8d5d5f02c703ce307610610eee4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_crosslang-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8a27347edffe81812a05bfc0cce073e75d55b05affa1abbeeeded13eee58838b
MD5 d49707f4d6dfcb15b4bf048bc486c151
BLAKE2b-256 d28d3f59d85a831565be2e756f2b1e5f40d9893019047fc3924aca187a300e3f

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