quickjs-ng 0.12.1.1__tar.gz

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.
Files changed (32) hide show
  1. quickjs_ng-0.12.1.1/LICENSE +21 -0
  2. quickjs_ng-0.12.1.1/PKG-INFO +161 -0
  3. quickjs_ng-0.12.1.1/README.md +139 -0
  4. quickjs_ng-0.12.1.1/module.c +914 -0
  5. quickjs_ng-0.12.1.1/pyproject.toml +121 -0
  6. quickjs_ng-0.12.1.1/quickjs/__init__.py +150 -0
  7. quickjs_ng-0.12.1.1/quickjs_ng.egg-info/PKG-INFO +161 -0
  8. quickjs_ng-0.12.1.1/quickjs_ng.egg-info/SOURCES.txt +30 -0
  9. quickjs_ng-0.12.1.1/quickjs_ng.egg-info/dependency_links.txt +1 -0
  10. quickjs_ng-0.12.1.1/quickjs_ng.egg-info/top_level.txt +2 -0
  11. quickjs_ng-0.12.1.1/setup.cfg +4 -0
  12. quickjs_ng-0.12.1.1/setup.py +61 -0
  13. quickjs_ng-0.12.1.1/tests/test_callable.py +145 -0
  14. quickjs_ng-0.12.1.1/tests/test_context.py +391 -0
  15. quickjs_ng-0.12.1.1/tests/test_js_features.py +715 -0
  16. quickjs_ng-0.12.1.1/tests/test_memory.py +92 -0
  17. quickjs_ng-0.12.1.1/tests/test_object.py +287 -0
  18. quickjs_ng-0.12.1.1/tests/test_threading.py +226 -0
  19. quickjs_ng-0.12.1.1/upstream-quickjs/cutils.h +1994 -0
  20. quickjs_ng-0.12.1.1/upstream-quickjs/dtoa.c +1619 -0
  21. quickjs_ng-0.12.1.1/upstream-quickjs/dtoa.h +87 -0
  22. quickjs_ng-0.12.1.1/upstream-quickjs/libregexp-opcode.h +58 -0
  23. quickjs_ng-0.12.1.1/upstream-quickjs/libregexp.c +2680 -0
  24. quickjs_ng-0.12.1.1/upstream-quickjs/libregexp.h +97 -0
  25. quickjs_ng-0.12.1.1/upstream-quickjs/libunicode-table.h +4707 -0
  26. quickjs_ng-0.12.1.1/upstream-quickjs/libunicode.c +1746 -0
  27. quickjs_ng-0.12.1.1/upstream-quickjs/libunicode.h +126 -0
  28. quickjs_ng-0.12.1.1/upstream-quickjs/list.h +107 -0
  29. quickjs_ng-0.12.1.1/upstream-quickjs/quickjs-atom.h +267 -0
  30. quickjs_ng-0.12.1.1/upstream-quickjs/quickjs-opcode.h +369 -0
  31. quickjs_ng-0.12.1.1/upstream-quickjs/quickjs.c +60021 -0
  32. quickjs_ng-0.12.1.1/upstream-quickjs/quickjs.h +1405 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ganesh Viswanathan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: quickjs-ng
3
+ Version: 0.12.1.1
4
+ Summary: Thin Python wrapper of quickjs-ng
5
+ Author-email: Ganesh Viswanathan <dev@genotrance.com>
6
+ Project-URL: Homepage, https://github.com/genotrance/quickjs-ng
7
+ Project-URL: Repository, https://github.com/genotrance/quickjs-ng
8
+ Keywords: quickjs,javascript,embedding
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: <4.0,>=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ # quickjs-ng
24
+
25
+ [![Build status](https://img.shields.io/github/actions/workflow/status/genotrance/quickjs-ng/main.yml?branch=main)](https://github.com/genotrance/quickjs-ng/actions/workflows/main.yml?query=branch%3Amain)
26
+ [![License](https://img.shields.io/github/license/genotrance/quickjs-ng)](https://img.shields.io/github/license/genotrance/quickjs-ng)
27
+
28
+ Python wrapper around [quickjs-ng](https://github.com/quickjs-ng/quickjs), the actively maintained fork of the [QuickJS](https://bellard.org/quickjs/) JavaScript engine.
29
+
30
+ Drop-in replacement for the archived [quickjs](https://github.com/PetterS/quickjs) package — `import quickjs` works unchanged.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install quickjs-ng
36
+ ```
37
+
38
+ Requires Python ≥ 3.10. Pre-built wheels are available for Linux (x86_64, i686, aarch64), Windows (AMD64, x86), and macOS (arm64), for CPython 3.10+ and PyPy 3.10/3.11.
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ import quickjs
44
+
45
+ # Evaluate expressions
46
+ ctx = quickjs.Context()
47
+ ctx.eval("1 + 2") # => 3
48
+
49
+ # Call JS functions from Python
50
+ ctx.eval("function add(a, b) { return a + b; }")
51
+ add = ctx.get("add")
52
+ add(3, 4) # => 7
53
+
54
+ # Call Python functions from JS
55
+ ctx.add_callable("py_add", lambda a, b: a + b)
56
+ ctx.eval("py_add(3, 4)") # => 7
57
+
58
+ # Use the Function helper for thread-safe execution
59
+ f = quickjs.Function("f", "function f(x) { return x * 2; }")
60
+ f(21) # => 42
61
+
62
+ # Resource limits
63
+ ctx.set_memory_limit(1024 * 1024) # 1 MB
64
+ ctx.set_time_limit(5) # 5 seconds of CPU time
65
+ ctx.set_max_stack_size(512 * 1024) # 512 KB stack
66
+ ```
67
+
68
+ ## Threading
69
+
70
+ Each `Context` owns an isolated QuickJS runtime — there is no shared state between contexts. A single `Context` is **not thread-safe** and must not be used from multiple threads.
71
+
72
+ **Recommended patterns:**
73
+
74
+ - **Context per thread** — create a separate `Context` in each thread. No locking, no overhead, full parallelism:
75
+
76
+ ```python
77
+ import threading, quickjs
78
+
79
+ def worker():
80
+ ctx = quickjs.Context()
81
+ print(ctx.eval("1 + 1"))
82
+
83
+ threads = [threading.Thread(target=worker) for _ in range(4)]
84
+ for t in threads: t.start()
85
+ ```
86
+
87
+ - **`Function` helper** — wraps a `Context` with a dedicated worker thread and lock, safe to call from any thread:
88
+
89
+ ```python
90
+ f = quickjs.Function("f", "function f(x) { return x * 2; }")
91
+ # safe to call f(21) from any thread
92
+ ```
93
+
94
+ | Pattern | Thread-safe | Overhead |
95
+ |---------|:-----------:|----------|
96
+ | Context per thread | ✅ | None |
97
+ | `Function` helper | ✅ | Small (executor dispatch) |
98
+ | Shared `Context` | ❌ | — |
99
+
100
+ **Free-threaded Python (3.13t / 3.14t):** Both patterns remain safe. The GIL was never relied upon for thread-safety.
101
+
102
+ **musl / Alpine:** Worker threads are automatically created with an 8 MB stack (matching glibc defaults) so `set_max_stack_size` and deep recursion work correctly on musl-based systems.
103
+
104
+ ## Versioning
105
+
106
+ Version format is `X.Y.Z.P` where `X.Y.Z` matches the upstream quickjs-ng tag and `P` is the wrapper patch (starts at 1 per upstream release). Wheels are built automatically when a new upstream tag is detected.
107
+
108
+ ## Development
109
+
110
+ Requires a C compiler and [uv](https://docs.astral.sh/uv/).
111
+
112
+ ```bash
113
+ git clone --recurse-submodules https://github.com/genotrance/quickjs-ng.git
114
+ cd quickjs-ng
115
+ make install
116
+ make test
117
+ ```
118
+
119
+ | Target | Description |
120
+ |----------------|----------------------------------------------------|
121
+ | `make install` | Create venv, build C extension, install pre-commit |
122
+ | `make test` | Run tests with coverage |
123
+ | `make check` | Run linters and type checking |
124
+ | `make build` | Build sdist and wheel |
125
+ | `make clean` | Remove build artifacts |
126
+ | `make publish` | Publish to PyPI |
127
+
128
+ ## Contributing
129
+
130
+ Bug reports and pull requests are welcome at <https://github.com/genotrance/quickjs-ng/issues>.
131
+
132
+ 1. Fork and clone with `--recurse-submodules`.
133
+ 2. Run `make install` to set up the venv, build the C extension, and install pre-commit hooks.
134
+ 3. Create a feature branch, make changes, add tests in `tests/`.
135
+ 4. Run `make check && make test` — all checks must pass.
136
+ 5. Open a pull request. CI runs on Ubuntu, Windows, and macOS across Python 3.10–3.14 (including free-threaded 3.13t/3.14t) and PyPy 3.10/3.11.
137
+
138
+ ## Documentation
139
+
140
+ Full technical documentation is in the [`docs/`](docs/) folder:
141
+
142
+ | File | Contents |
143
+ |------|----------|
144
+ | [docs/porting.md](docs/porting.md) | Porting history from PetterS/quickjs |
145
+ | [docs/c-extension.md](docs/c-extension.md) | C extension design and stable ABI migration |
146
+ | [docs/build.md](docs/build.md) | Build system: setup.py, pyproject.toml, wheels |
147
+ | [docs/ci.md](docs/ci.md) | GitHub Actions workflows |
148
+ | [docs/threading.md](docs/threading.md) | Threading model and musl stack fix |
149
+ | [docs/testing.md](docs/testing.md) | Test suite layout and memory leak tests |
150
+ | [docs/versioning.md](docs/versioning.md) | Version scheme and automated stamping |
151
+ | [docs/typing.md](docs/typing.md) | Type annotations and mypy configuration |
152
+
153
+ ## Acknowledgments
154
+
155
+ This project is a fork of [quickjs](https://github.com/PetterS/quickjs) by [Petter Strandmark](https://github.com/PetterS). The original design of the C bindings, the `Function` thread-safety wrapper, and the overall API shape are all his work.
156
+
157
+ The porting to quickjs-ng, the stable ABI migration, the expanded test suite, CICD and all documentation were developed with the assistance of LLMs.
158
+
159
+ ## License
160
+
161
+ MIT
@@ -0,0 +1,139 @@
1
+ # quickjs-ng
2
+
3
+ [![Build status](https://img.shields.io/github/actions/workflow/status/genotrance/quickjs-ng/main.yml?branch=main)](https://github.com/genotrance/quickjs-ng/actions/workflows/main.yml?query=branch%3Amain)
4
+ [![License](https://img.shields.io/github/license/genotrance/quickjs-ng)](https://img.shields.io/github/license/genotrance/quickjs-ng)
5
+
6
+ Python wrapper around [quickjs-ng](https://github.com/quickjs-ng/quickjs), the actively maintained fork of the [QuickJS](https://bellard.org/quickjs/) JavaScript engine.
7
+
8
+ Drop-in replacement for the archived [quickjs](https://github.com/PetterS/quickjs) package — `import quickjs` works unchanged.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pip install quickjs-ng
14
+ ```
15
+
16
+ Requires Python ≥ 3.10. Pre-built wheels are available for Linux (x86_64, i686, aarch64), Windows (AMD64, x86), and macOS (arm64), for CPython 3.10+ and PyPy 3.10/3.11.
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ import quickjs
22
+
23
+ # Evaluate expressions
24
+ ctx = quickjs.Context()
25
+ ctx.eval("1 + 2") # => 3
26
+
27
+ # Call JS functions from Python
28
+ ctx.eval("function add(a, b) { return a + b; }")
29
+ add = ctx.get("add")
30
+ add(3, 4) # => 7
31
+
32
+ # Call Python functions from JS
33
+ ctx.add_callable("py_add", lambda a, b: a + b)
34
+ ctx.eval("py_add(3, 4)") # => 7
35
+
36
+ # Use the Function helper for thread-safe execution
37
+ f = quickjs.Function("f", "function f(x) { return x * 2; }")
38
+ f(21) # => 42
39
+
40
+ # Resource limits
41
+ ctx.set_memory_limit(1024 * 1024) # 1 MB
42
+ ctx.set_time_limit(5) # 5 seconds of CPU time
43
+ ctx.set_max_stack_size(512 * 1024) # 512 KB stack
44
+ ```
45
+
46
+ ## Threading
47
+
48
+ Each `Context` owns an isolated QuickJS runtime — there is no shared state between contexts. A single `Context` is **not thread-safe** and must not be used from multiple threads.
49
+
50
+ **Recommended patterns:**
51
+
52
+ - **Context per thread** — create a separate `Context` in each thread. No locking, no overhead, full parallelism:
53
+
54
+ ```python
55
+ import threading, quickjs
56
+
57
+ def worker():
58
+ ctx = quickjs.Context()
59
+ print(ctx.eval("1 + 1"))
60
+
61
+ threads = [threading.Thread(target=worker) for _ in range(4)]
62
+ for t in threads: t.start()
63
+ ```
64
+
65
+ - **`Function` helper** — wraps a `Context` with a dedicated worker thread and lock, safe to call from any thread:
66
+
67
+ ```python
68
+ f = quickjs.Function("f", "function f(x) { return x * 2; }")
69
+ # safe to call f(21) from any thread
70
+ ```
71
+
72
+ | Pattern | Thread-safe | Overhead |
73
+ |---------|:-----------:|----------|
74
+ | Context per thread | ✅ | None |
75
+ | `Function` helper | ✅ | Small (executor dispatch) |
76
+ | Shared `Context` | ❌ | — |
77
+
78
+ **Free-threaded Python (3.13t / 3.14t):** Both patterns remain safe. The GIL was never relied upon for thread-safety.
79
+
80
+ **musl / Alpine:** Worker threads are automatically created with an 8 MB stack (matching glibc defaults) so `set_max_stack_size` and deep recursion work correctly on musl-based systems.
81
+
82
+ ## Versioning
83
+
84
+ Version format is `X.Y.Z.P` where `X.Y.Z` matches the upstream quickjs-ng tag and `P` is the wrapper patch (starts at 1 per upstream release). Wheels are built automatically when a new upstream tag is detected.
85
+
86
+ ## Development
87
+
88
+ Requires a C compiler and [uv](https://docs.astral.sh/uv/).
89
+
90
+ ```bash
91
+ git clone --recurse-submodules https://github.com/genotrance/quickjs-ng.git
92
+ cd quickjs-ng
93
+ make install
94
+ make test
95
+ ```
96
+
97
+ | Target | Description |
98
+ |----------------|----------------------------------------------------|
99
+ | `make install` | Create venv, build C extension, install pre-commit |
100
+ | `make test` | Run tests with coverage |
101
+ | `make check` | Run linters and type checking |
102
+ | `make build` | Build sdist and wheel |
103
+ | `make clean` | Remove build artifacts |
104
+ | `make publish` | Publish to PyPI |
105
+
106
+ ## Contributing
107
+
108
+ Bug reports and pull requests are welcome at <https://github.com/genotrance/quickjs-ng/issues>.
109
+
110
+ 1. Fork and clone with `--recurse-submodules`.
111
+ 2. Run `make install` to set up the venv, build the C extension, and install pre-commit hooks.
112
+ 3. Create a feature branch, make changes, add tests in `tests/`.
113
+ 4. Run `make check && make test` — all checks must pass.
114
+ 5. Open a pull request. CI runs on Ubuntu, Windows, and macOS across Python 3.10–3.14 (including free-threaded 3.13t/3.14t) and PyPy 3.10/3.11.
115
+
116
+ ## Documentation
117
+
118
+ Full technical documentation is in the [`docs/`](docs/) folder:
119
+
120
+ | File | Contents |
121
+ |------|----------|
122
+ | [docs/porting.md](docs/porting.md) | Porting history from PetterS/quickjs |
123
+ | [docs/c-extension.md](docs/c-extension.md) | C extension design and stable ABI migration |
124
+ | [docs/build.md](docs/build.md) | Build system: setup.py, pyproject.toml, wheels |
125
+ | [docs/ci.md](docs/ci.md) | GitHub Actions workflows |
126
+ | [docs/threading.md](docs/threading.md) | Threading model and musl stack fix |
127
+ | [docs/testing.md](docs/testing.md) | Test suite layout and memory leak tests |
128
+ | [docs/versioning.md](docs/versioning.md) | Version scheme and automated stamping |
129
+ | [docs/typing.md](docs/typing.md) | Type annotations and mypy configuration |
130
+
131
+ ## Acknowledgments
132
+
133
+ This project is a fork of [quickjs](https://github.com/PetterS/quickjs) by [Petter Strandmark](https://github.com/PetterS). The original design of the C bindings, the `Function` thread-safety wrapper, and the overall API shape are all his work.
134
+
135
+ The porting to quickjs-ng, the stable ABI migration, the expanded test suite, CICD and all documentation were developed with the assistance of LLMs.
136
+
137
+ ## License
138
+
139
+ MIT