akracer

0.0.14 · active · verified Tue Apr 14

akracer is a Python library that serves as an extension for py_mini_racer, specifically designed to address dynamic link library (DLL) calling issues on 64-bit ARM operating systems. It facilitates a one-click installation of py_mini_racer by providing pre-compiled dynamic link libraries for environments like Apple M-series chips, Ubuntu (18.04, 20.04, 22.04), and Raspberry Pi 64-bit OS. The current version is 0.0.14. It is actively maintained with a beta development status.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of py_mini_racer, which akracer enables by providing the necessary underlying binaries, especially for ARM-based systems. It shows how to evaluate JavaScript expressions and call JavaScript functions within a Python environment.

import os
from py_mini_racer import MiniRacer

# Initialize a MiniRacer context
context = MiniRacer()

# Evaluate JavaScript code
result = context.eval("1 + 1")
print(f"Result of '1 + 1': {result}")

# Call a JavaScript function
context.eval("var add = function(a, b) { return a + b; };")
add_result = context.call("add", 5, 3)
print(f"Result of add(5, 3): {add_result}")

# Example using a JavaScript file (simulate loading a file)
js_content = """
var greet = function(name) {
    return 'Hello, ' + name + '!';
};
"""
context.eval(js_content)
greet_result = context.call("greet", "World")
print(f"Result of greet('World'): {greet_result}")

view raw JSON →