Skip to main content

PyExecJS

Run JavaScript code from Python.

PyExecJS is a porting of ExecJS from Ruby. PyExecJS automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Python object.

A short example:

>>> import execjs
>>> execjs.eval("'red yellow blue'.split(' ')")
['red', 'yellow', 'blue']
>>> ctx = execjs.compile("""
...     function add(x, y) {
...         return x + y;
...     }
... """)
>>> ctx.call("add", 1, 2)
3

Of course, you can pick particular JavaScript runtime by get() function:

>>> default = execjs.get() # the automatically picked runtime
>>> default.eval("1 + 2")
3
>>> jscript = execjs.get("JScript")
>>> jscript.eval("1 + 2")
3
>>> node = execjs.get("Node")
>>> node.eval("1 + 2")
3

If EXECJS_RUNTIME environment variable is specified, PyExecJS pick the JavaScript runtime as a default:

>>> #execjs.get().name # this value is depends on your environment.
>>> os.environ["EXECJS_RUNTIME"] = "Node"
>>> execjs.get().name
'Node.js (V8)'

PyExecJS supports these runtimes:

Installation

$ pip install PyExecJS

or

$ easy_install PyExecJS

License

Copyright (c) 2012 Omoto Kenji. Copyright (c) 2011 Sam Stephenson and Josh Peek.

Released under the MIT license. See LICENSE for details.

Changes

1.0.5

  • Supported Python 3.3

  • Fixed file handle leaking

  • Fixed issue with passenger-nginx-4.0

1.0.4

  • Removed “import execjs” (it prevent execution of setup.py by Python 2.6)

1.0.3

  • Javascript sources were embeded in init.py. ‘which’ command were reimplemented by pure python.

1.0.2

  • Python 2.6.x was supported.

1.0.1

  • Forgotten shell=True was added to Popen.

1.0.0

  • First release.

Metadata

Release files for PyExecJS 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for PyExecJS 1.0.5
File Size Uploaded Provenance Actions
PyExecJS-1.0.5.zip 15.6 kB Without provenance Details for PyExecJS-1.0.5.zip
PyExecJS-1.0.5.tar.gz 10.1 kB Without provenance Details for PyExecJS-1.0.5.tar.gz

Release files / PyExecJS-1.0.5.zip

Download URL PyExecJS-1.0.5.zip
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0ddfb6cc6de41dc1c2def52134ec26146acb9679b71c38692618b63108579ab7
BLAKE2b-256 checksum
How to use checksums
12ffaf8bf21e2d6ae48280ca1e28e781cd2c138b188e63058b00289734622a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / PyExecJS-1.0.5.tar.gz

Download URL PyExecJS-1.0.5.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
95adfddc64aaf95d330c715a248ce0ff32facf33740c6de619658b5c588939fb
BLAKE2b-256 checksum
How to use checksums
a5d36068858d2c34cea1ad4dd24184758c9904c7dc1293146bb6bf9f09812da0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for PyExecJS 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page