v8-python 0.1.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
v8/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .v8 import *
2
+
3
+ __doc__ = v8.__doc__
4
+ if hasattr(v8, "__all__"):
5
+ __all__ = v8.__all__
Binary file
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: v8-python
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
13
+ Summary: Python bindings for embedding V8 with denoland/rusty_v8.
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
16
+
17
+ # v8-python
18
+
19
+ Python bindings for embedding V8 and running JavaScript, built on
20
+ `denoland/rusty_v8`.
21
+
22
+ `v8-python` lets Python code create V8 isolates and contexts, evaluate
23
+ JavaScript, pass values between Python and JavaScript, expose Python functions
24
+ and classes to JavaScript, and install host APIs such as timers, console,
25
+ module loading, and WebAssembly. It is implemented in Rust using
26
+ `denoland/rusty_v8`.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install v8-python
32
+ ```
33
+
34
+ For local development:
35
+
36
+ ```bash
37
+ uv run maturin develop
38
+ ```
39
+
40
+ ## Tutorial
41
+
42
+ ### Run JavaScript
43
+
44
+ ```python
45
+ import v8
46
+
47
+ isolate = v8.Isolate()
48
+ builder = isolate.create_context_builder()
49
+ context = builder.build()
50
+
51
+ result = context.eval("'Hello' + ' from V8'")
52
+ print(result)
53
+ ```
54
+
55
+ ### Expose a Python function
56
+
57
+ ```python
58
+ import v8
59
+
60
+ isolate = v8.Isolate()
61
+ builder = isolate.create_context_builder()
62
+
63
+
64
+ @builder.host_function(name="add")
65
+ def add(left: int, right: int) -> int:
66
+ return left + right
67
+
68
+
69
+ context = builder.build()
70
+ print(context.eval("add(20, 22)"))
71
+ ```
72
+
73
+ ### Install host APIs
74
+
75
+ Host APIs are installed through a profile. This keeps the context builder small
76
+ and makes reusable runtime setups easy to share.
77
+
78
+ ```python
79
+ import v8
80
+
81
+ profile = v8.BaseProfile().install([v8.api.Timer()])
82
+
83
+ isolate = v8.Isolate()
84
+ builder = isolate.create_context_builder()
85
+ builder.use_profile(profile)
86
+ context = builder.build()
87
+
88
+ context.eval(
89
+ """
90
+ globalThis.events = [];
91
+ setTimeout(() => events.push("ready"), 0);
92
+ """
93
+ )
94
+
95
+ context.run_until_idle(max_tasks=10)
96
+ print(context.eval("events.join(', ')"))
97
+ ```
98
+
99
+ ### Await a JavaScript Promise
100
+
101
+ JavaScript promises can be awaited from Python.
102
+
103
+ ```python
104
+ import asyncio
105
+ import v8
106
+
107
+ isolate = v8.Isolate()
108
+ builder = isolate.create_context_builder()
109
+ context = builder.build()
110
+
111
+
112
+ async def main():
113
+ return await context.eval("Promise.resolve('done')")
114
+
115
+
116
+ print(asyncio.run(main()))
117
+ ```
118
+
119
+ More focused examples are available in the `examples/` directory.
120
+
121
+ ## Documentation
122
+
123
+ ```bash
124
+ uv run --group doc zensical serve
125
+ ```
126
+
@@ -0,0 +1,6 @@
1
+ v8/__init__.py,sha256=QMcom8iHkz1leg33TjH_aqKE_1TCJiGF_nT-F6ce-To,91
2
+ v8/v8.cp313-win_amd64.pyd,sha256=5urTGwKeZRVcx44xWrbEBmTnaL3-lTn2Tb8HvSpTWeQ,33169408
3
+ v8_python-0.1.0.dist-info/METADATA,sha256=b1QwrxsTivXNlLFg7QQ4wOOG7anVTrP83UZKj3nbzE0,2815
4
+ v8_python-0.1.0.dist-info/WHEEL,sha256=TDIE_VZkwaFwJY0Olvlg1LUe0IwzGBwZhAVXfIDdWJc,97
5
+ v8_python-0.1.0.dist-info/sboms/v8-python.cyclonedx.json,sha256=oaDt2yFiN6fBLevsGgmJoUGKN0M2WUfJixW-wrRFcPs,177300
6
+ v8_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.13.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64