Write Python APIs, then call them from JavaScript using the V8 engine.
Project description
Write Python APIs, then call them from JavaScript using the V8 engine.
>>> from v8py import Context
>>> context = Context()
>>> def print_hello():
... print 'Hello, world!'
>>> context.expose(print_hello)
>>> context.eval('print_hello()')
Hello, world!
>>> class Greeter(object):
... def greet(self, thing):
... print 'Welcome, {}!'.format(thing)
>>> context.expose(Greeter)
>>> context.eval('g = new Greeter()')
>>> context.eval('g.greet("V8Py")')
Welcome, V8Py!
That kind of thing.
Almost everything you’d expect to work just works, including:
Functions
Classes (including old style classes, because I can)
Data descriptors
Static methods and class methods
Exceptions (they even subclass from Error!)
Installation
If you have a Mac running OS X 10.12, you can do
$ pip install v8py
If not, you can still try that, but it’ll be stuck at “Running setup.py install for v8py” for literally hours. (It’s downloading and building V8, which is a really big program.) I hope to get more wheels built soon.
Misc
I (sometimes) stream development of this and related projects at https://twitch.tv/tblodt.
There is no documentation of any of this yet. No docstrings. The best place to look to find out how to use it is the tests.
I’m writing this so I can create a really lightweight special-purpose webdriver (no visual rendering, no asynchronous XHRs), and I need some way of implementing the DOM in Python. So there will definitely be enough functionality for that.
If you’d like to use it for something else, by all means go ahead, but you may find something that doesn’t quite “just work”, or works kind of strangely, or just stuff I forgot to test. If you find anything, please submit an issue. Or, even better, send a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for v8py-0.9.9-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fc3383edace3d1b58d7d4a205940ea9fbffcf3389cd820f7de00c279074b248 |
|
MD5 | 071de42214bcb52cabaa79400fbd7149 |
|
BLAKE2b-256 | 4fe0c8ee5b4e7051d508520bafc0bfddeaddc1d4b03764f7dbe19e66a506a1ea |
Hashes for v8py-0.9.9-cp27-cp27m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69415c7843091c72c826148a8d12eea722a1fa847125311b3f797ccc176bf915 |
|
MD5 | b9c694249e3c3062e440e75964b85238 |
|
BLAKE2b-256 | 63cceaca5ea9a8bf03c30c28fb7e4e2a5f962fa63cf7b6a34d5c28b39e508430 |