{"id":5384,"library":"py-mini-racer","title":"PyMiniRacer (Original - Deprecated)","description":"PyMiniRacer is a Python library that provides a minimal and modern embedded V8 JavaScript engine for Python. It allows Python applications to execute JavaScript code, supporting the latest ECMAScript features and Web Assembly. Developed by Sqreen, this original project is at version 0.6.0 and has been superseded by the `mini-racer` library under a new maintainer.","status":"deprecated","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/sqreen/PyMiniRacer","tags":["javascript","v8","js-engine","embedding","deprecated"],"install":[{"cmd":"pip install py-mini-racer","lang":"bash","label":"Install py-mini-racer"}],"dependencies":[{"reason":"Required for Alpine Linux if building from source or for specific wheels.","package":"libgcc","optional":true},{"reason":"Required for Alpine Linux if building from source or for specific wheels.","package":"libstdc++","optional":true}],"imports":[{"note":"The primary class for interacting with the V8 engine.","symbol":"MiniRacer","correct":"from py_mini_racer import MiniRacer"}],"quickstart":{"code":"from py_mini_racer import MiniRacer\n\n# Create a new MiniRacer context\nctx = MiniRacer()\n\n# Evaluate JavaScript code\nresult = ctx.eval(\"1 + 1\")\nprint(f\"1 + 1 = {result}\")\n\n# Evaluate more complex JavaScript with variables\nctx.eval(\"var x = {company: 'Acme'};\")\ncompany_name = ctx.eval(\"x.company\")\nprint(f\"Company name: {company_name}\")\n\n# Use .call() for composite types, .eval() for primitives\ndef_func = ctx.eval(\"var fun = () => ({ foo: 1 });\")\ncomposite_result = ctx.call(\"fun\")\nprint(f\"Composite result: {composite_result}\")","lang":"python","description":"This quickstart demonstrates how to initialize a `MiniRacer` context and execute basic JavaScript code using `eval()` and `call()`. `eval()` is suitable for primitive return types, while `call()` is used for composite types like objects, which are serialized via JSON."},"warnings":[{"fix":"Migrate to the `mini-racer` library by installing `pip install mini-racer` and updating import statements if necessary. Consult the `mini-racer` documentation for migration details.","message":"The `py-mini-racer` library (sqreen/PyMiniRacer) is deprecated and no longer actively maintained. The recommended successor project is `mini-racer` (bpcreech/PyMiniRacer), which provides updated V8 versions and continued development. Users are strongly encouraged to migrate.","severity":"breaking","affected_versions":"<=0.6.0"},{"fix":"Review application architecture for multi-process or multi-threaded JavaScript execution. If multi-threading within V8 is critical, investigate the `mini-racer` successor which might offer different configuration options or alternative solutions.","message":"As of v0.6.0, V8 was switched to single-threaded mode by default to prevent crashes after process forks. If your application relied on multi-threaded V8 operations within the same process or expected specific behavior after forking, this change might affect stability or performance.","severity":"breaking","affected_versions":"0.6.0"},{"fix":"Ensure all JavaScript code executed within PyMiniRacer is compliant with ECMAScript strict mode. This typically involves fixing common JavaScript 'sloppy mode' practices.","message":"Version 0.6.0 switched V8 to strict mode by default. JavaScript code that previously ran without issues in non-strict mode (e.g., using undeclared variables, duplicate parameter names) might now throw errors.","severity":"breaking","affected_versions":"0.6.0"},{"fix":"Prefer installing pre-built wheels (`pip install py-mini-racer`). If building from source is necessary, ensure you have sufficient disk space, time, and the correct Python 2.7 environment for the V8 build steps (even if using Python 3 for the final package). Consider using the `mini-racer` package, which has more modern build processes.","message":"Building PyMiniRacer from source is a resource-intensive process, requiring several GB of disk space and approximately 60 minutes. Furthermore, the V8 build system historically required a Python 2.7 executable.","severity":"gotcha","affected_versions":"<=0.6.0"},{"fix":"Use `ctx.call(\"functionName\", args...)` when expecting JavaScript objects, arrays, or other composite structures as return values. Use `ctx.eval(\"jsExpression\")` for primitive returns.","message":"The `eval()` method in `py-mini-racer` only supports returning primitive data types (numbers, strings, buffers). To return composite types like JavaScript objects or arrays, you must use the `call()` method.","severity":"gotcha","affected_versions":"<=0.6.0"},{"fix":"Design your application to handle callbacks from JavaScript to Python using alternative mechanisms (e.g., polling for results, or re-evaluating context in Python). The successor `mini-racer` introduced `wrap_py_function` for this functionality in v0.12.0.","message":"This version of PyMiniRacer does not support attaching Python objects or functions to the JavaScript context, meaning you cannot directly call Python code from JavaScript.","severity":"gotcha","affected_versions":"<=0.6.0"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}