Skip to content

sqreen/PyMiniRacer

Repository files navigation

Python Mini Racer

Documentation Status

Minimal, modern embedded V8 for Python.

Features

  • Unicode support
  • Thread safe
  • Re-usable contexts
  • Binary object is Python agnostic

Examples

py_mini_racer is straightforward to use:

>>> from py_mini_racer import py_mini_racer
>>> ctx = py_mini_racer.Context()
>>> ctx.eval('1+1')
2
>>> ctx.eval("var x = {company: 'Sqreen'}; x.company")
u'Sqreen'
>>> print ctx.eval(u"'\N{HEAVY BLACK HEART}'")
❤
>>> ctx.eval("var fun = () => ({ foo: 1 });")
>>> ctx.call("fun")
{u'foo': 1}

Installation

We built Python wheels (prebuilt binaries) for OSX 64 bits and Linux 32 & 64 bits. You need pip >= 1.4 and setuptools >= 0.8.

$ pip install pyminiracer

Build

You can build v8 with the command:

$ python setup.py build_v8

You can also build the ctype extension:

$ python setup.py build_ext

Which automatically build v8.

You can generate a wheel with the command:

$ python setup.py bdist_wheel

which builds v8, the extension, and generates a wheel.

Tests

If you want to run the tests, you need to build V8 first, then launch:

$ python setup.py test --addopts tests

Credits

PyMiniRacer is inspired by mini_racer, built for the Ruby world by Sam Saffron.

Tools used in rendering this package: