Skip to main content

Minimal, modern embedded V8 for Python.

Project description

https://img.shields.io/pypi/v/py_mini_racer.svg

Minimal, modern embedded V8 for Python.

  • Free software: ISC license

https://github.com/sqreen/PyMiniRacer/raw/master/data/py_mini_racer.png

Features

  • Unicode support

  • Thread safe

  • Re-usable contexts

  • Binary object is Python agnostic

MiniRacer can be easily used by Django or Flask projects to minify assets, run babel or compile CoffeeScript.

Examples

py_mini_racer is straightforward to use:

>>> from py_mini_racer import py_mini_racer
>>> ctx = py_mini_racer.MiniRacer()
>>> 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}

Variables are kept inside of a context:

>>> ctx.eval("x.company")
u'Sqreen'
[1,2,3].map(n => n + 1);

Compatibility

PyMiniRacer is only compatible with Python 2.7 at the moment. Python 3 support is on its way.

Binary builds availability

The PyMiniRacer binary builds have been tested on x86_64 with:

  • OSX 10.11

  • Ubuntu >= 14.04

  • Debian >= 8

  • CentOS >= 7

You need pip >= 8.1 to install the wheels - you can check and upgrade yours in this way:

$ pip --version
$ pip install --upgrade pip

It should work on any Linux with a libc >= 2.17 and a wheel compatible pip (>= 8.1).

If you have a up-to-date pip and it doesn’t use a wheel, you might have an environment for which no wheel is built. Please open an issue.

Installation

We built Python wheels (prebuilt binaries) for OSX 64 bits and Linux 64 bits - most recent distributions. You need pip >= 1.4 and setuptools >= 0.8.

$ pip install py-mini-racer

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 builds 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

Built with love by Sqreen.

PyMiniRacer launch was described in this blog post.

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

Tools used in rendering this package:

Todo

Lower libc version needed. Export V8 version. Fix circular structures export.

History

UNRELEASED

0.1.8 (2017-03-02)

  • Update targets build for better compatibility with old Mac OS X and linux platforms.

0.1.7 (2016-10-04)

  • Improve general performances of the JS execution.

  • Add the possibility to build a different version of V8 (for example with debug symbols).

  • Fix a conflict that could happens between statically linked libraries and dynamic ones.

0.1.6 (2016-08-12)

  • Add error message when py_mini_racer sdist fails to build asking to update pip in order to download the pre-compiled wheel instead of the source distribution.

0.1.5 (2016-08-04)

  • Build py_mini_racer against a static Python. When built against a shared library python, it doesn’t work with a static Python.

0.1.4 (2016-08-04)

  • Ensure JSEvalException message is converted to unicode

0.1.3 (2016-08-04)

  • Fix extension loading for python3

  • Add a make target for building distributions (sdist + wheels)

  • Fix eval conversion for python 3

0.1.2 (2016-08-03)

  • Fix date support

  • Fix Dockerfile for generating python3 wheels

0.1.1 (2016-08-02)

  • Fix sdist distribution.

0.1.0 (2016-08-01)

  • First release on PyPI.

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

py_mini_racer-0.1.8.tar.gz (325.5 kB view details)

Uploaded Source

Built Distributions

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

py_mini_racer-0.1.8-cp36-cp36m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.6m

py_mini_racer-0.1.8-cp36-cp36m-macosx_10_6_intel.whl (4.1 MB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

py_mini_racer-0.1.8-cp35-cp35m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.5m

py_mini_racer-0.1.8-cp35-cp35m-macosx_10_6_intel.whl (4.1 MB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

py_mini_racer-0.1.8-cp34-cp34m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.4m

py_mini_racer-0.1.8-cp34-cp34m-macosx_10_6_intel.whl (4.1 MB view details)

Uploaded CPython 3.4mmacOS 10.6+ Intel (x86-64, i386)

py_mini_racer-0.1.8-cp27-cp27mu-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 2.7mu

py_mini_racer-0.1.8-cp27-cp27m-manylinux1_x86_64.whl (4.6 MB view details)

Uploaded CPython 2.7m

py_mini_racer-0.1.8-cp27-cp27m-macosx_10_6_intel.whl (4.1 MB view details)

Uploaded CPython 2.7mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file py_mini_racer-0.1.8.tar.gz.

File metadata

  • Download URL: py_mini_racer-0.1.8.tar.gz
  • Upload date:
  • Size: 325.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py_mini_racer-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8fc04d8b3b681fa934a7c29781fb0350ef4137214e08397b468b46f49aa7a0ac
MD5 f0aab87c4e9321e3dd3240ac5d4ef556
BLAKE2b-256 2315f35838c65d08b5668977691717e666f8178f76c8e5f99332556b7a935320

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e1bf73de8ba9e38d5a417fdffd8f8034e926c4a88d16842f71a8e999164d09a0
MD5 fb1354b36ae1d63bcab5ebeaf7a73e07
BLAKE2b-256 71b7c473430bf823645155a9ed7bbe0a20fa97af18d3ae32b5e8a33683955b42

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b61057388a9b102bb3a83466146f776a835bccf619aa23862f46bb6db0b1e56f
MD5 28065258be4fa2e6142c4ed102d8ea3e
BLAKE2b-256 2df7d0c8406978ba2930ef5b797b49fb95048249145e793485b8472548ae3305

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 eae5e03e9fd762778378bb80efe3ea739333a6ba28ec655f724e9d39ba715507
MD5 f5da107341388ba8296f8b9c6eb7f1c2
BLAKE2b-256 5edc61a60cc9b43012ace2df8229dc7552e1f0252d37735f38756da0c94d69cb

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a6c97d0f10cbaf8027902f9f21cfd98c2dc518709863e46cb1dc978c34832dfb
MD5 d55a6763311a3218ca6cf33ee102b8a9
BLAKE2b-256 77805bdfa07bc77cc4d66afe4b00d7c8bca3846bf90ac178088dc18f061afd17

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 056b6a1caed50586a1463c362db2c7501c43eacd770a977a7ac8eddb84dc4c40
MD5 a8018b388dac657bce0a034e91cfb9c5
BLAKE2b-256 b2d5dbe1cd34063e804be86467fac5bfcab5d078981c60eee7ccd2f51a546034

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 fe456051ef17a73528c4937ed27d16318792ca2e5850f4a6e8988dc84f69ffc2
MD5 73ecb8e5b7484e45c0999f075afb83c2
BLAKE2b-256 87a34f39800b311231ffe800e79282a6eafb87f80487ba1c08cfaf858bda2fe6

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cbe72e6fe8857a6ebf91228e3106611d0eb806b5cfe95182045876e83e4318b3
MD5 43ffebf645866f54bc1431944ab90f74
BLAKE2b-256 9908d7dee199aacd93cafe8070cd0fc0bd2f6008e8babafec8ad0601d7e3c58b

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9d529159335f84a2374f568a9d10f0b92d333266106677a56cdb286f53d4a192
MD5 93e86e1977011fd6bba8ace300dbce37
BLAKE2b-256 72346050435528d37fa625aca0aee100f7ddcd648952d8c2094d14d17b72775a

See more details on using hashes here.

File details

Details for the file py_mini_racer-0.1.8-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for py_mini_racer-0.1.8-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 2218519210e148c119829a80a2604718db3ea31452ea08caf304244c6b1fcfde
MD5 e84ee63489da1eb90980e41b245cb9af
BLAKE2b-256 ce98870916b97ada9d707e1d19d972285f3880af23605f8fb8d405adc9e4af86

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