datacut-native 0.1.0__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.
@@ -0,0 +1,2 @@
1
+ target/
2
+ dist/
@@ -0,0 +1,297 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "1.1.5"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "autocfg"
16
+ version = "1.5.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
19
+
20
+ [[package]]
21
+ name = "bit-set"
22
+ version = "0.8.0"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
25
+ dependencies = [
26
+ "bit-vec",
27
+ ]
28
+
29
+ [[package]]
30
+ name = "bit-vec"
31
+ version = "0.8.0"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
34
+
35
+ [[package]]
36
+ name = "datacut_native"
37
+ version = "0.1.0"
38
+ dependencies = [
39
+ "fancy-regex",
40
+ "numpy",
41
+ "pyo3",
42
+ "roxmltree",
43
+ ]
44
+
45
+ [[package]]
46
+ name = "fancy-regex"
47
+ version = "0.20.2"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "0a2e16b9a584b602f1e0e5e22c30ca0906786088c27500653e432d086def8b53"
50
+ dependencies = [
51
+ "bit-set",
52
+ "regex-automata",
53
+ "regex-syntax",
54
+ ]
55
+
56
+ [[package]]
57
+ name = "heck"
58
+ version = "0.5.0"
59
+ source = "registry+https://github.com/rust-lang/crates.io-index"
60
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
61
+
62
+ [[package]]
63
+ name = "libc"
64
+ version = "0.2.191"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
67
+
68
+ [[package]]
69
+ name = "matrixmultiply"
70
+ version = "0.3.11"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7"
73
+ dependencies = [
74
+ "autocfg",
75
+ "rawpointer",
76
+ ]
77
+
78
+ [[package]]
79
+ name = "memchr"
80
+ version = "2.8.3"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
83
+
84
+ [[package]]
85
+ name = "ndarray"
86
+ version = "0.17.2"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
89
+ dependencies = [
90
+ "matrixmultiply",
91
+ "num-complex",
92
+ "num-integer",
93
+ "num-traits",
94
+ "portable-atomic",
95
+ "portable-atomic-util",
96
+ "rawpointer",
97
+ ]
98
+
99
+ [[package]]
100
+ name = "num-complex"
101
+ version = "0.4.6"
102
+ source = "registry+https://github.com/rust-lang/crates.io-index"
103
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
104
+ dependencies = [
105
+ "num-traits",
106
+ ]
107
+
108
+ [[package]]
109
+ name = "num-integer"
110
+ version = "0.1.47"
111
+ source = "registry+https://github.com/rust-lang/crates.io-index"
112
+ checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
113
+ dependencies = [
114
+ "num-traits",
115
+ ]
116
+
117
+ [[package]]
118
+ name = "num-traits"
119
+ version = "0.2.19"
120
+ source = "registry+https://github.com/rust-lang/crates.io-index"
121
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
122
+ dependencies = [
123
+ "autocfg",
124
+ ]
125
+
126
+ [[package]]
127
+ name = "numpy"
128
+ version = "0.30.0"
129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
130
+ checksum = "aa0b9111761885449e894981fa8051dcf69e0bd114aecbd4bcdd830b6be4ed92"
131
+ dependencies = [
132
+ "libc",
133
+ "ndarray",
134
+ "num-complex",
135
+ "num-integer",
136
+ "num-traits",
137
+ "pyo3",
138
+ "pyo3-build-config",
139
+ "rustc-hash",
140
+ ]
141
+
142
+ [[package]]
143
+ name = "once_cell"
144
+ version = "1.21.4"
145
+ source = "registry+https://github.com/rust-lang/crates.io-index"
146
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
147
+
148
+ [[package]]
149
+ name = "portable-atomic"
150
+ version = "1.15.0"
151
+ source = "registry+https://github.com/rust-lang/crates.io-index"
152
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
153
+
154
+ [[package]]
155
+ name = "portable-atomic-util"
156
+ version = "0.2.8"
157
+ source = "registry+https://github.com/rust-lang/crates.io-index"
158
+ checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
159
+ dependencies = [
160
+ "portable-atomic",
161
+ ]
162
+
163
+ [[package]]
164
+ name = "proc-macro2"
165
+ version = "1.0.107"
166
+ source = "registry+https://github.com/rust-lang/crates.io-index"
167
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
168
+ dependencies = [
169
+ "unicode-ident",
170
+ ]
171
+
172
+ [[package]]
173
+ name = "pyo3"
174
+ version = "0.30.1"
175
+ source = "registry+https://github.com/rust-lang/crates.io-index"
176
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
177
+ dependencies = [
178
+ "libc",
179
+ "once_cell",
180
+ "portable-atomic",
181
+ "pyo3-build-config",
182
+ "pyo3-ffi",
183
+ "pyo3-macros",
184
+ ]
185
+
186
+ [[package]]
187
+ name = "pyo3-build-config"
188
+ version = "0.30.1"
189
+ source = "registry+https://github.com/rust-lang/crates.io-index"
190
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
191
+ dependencies = [
192
+ "target-lexicon",
193
+ ]
194
+
195
+ [[package]]
196
+ name = "pyo3-ffi"
197
+ version = "0.30.1"
198
+ source = "registry+https://github.com/rust-lang/crates.io-index"
199
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
200
+ dependencies = [
201
+ "libc",
202
+ "pyo3-build-config",
203
+ ]
204
+
205
+ [[package]]
206
+ name = "pyo3-macros"
207
+ version = "0.30.1"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
210
+ dependencies = [
211
+ "proc-macro2",
212
+ "pyo3-macros-backend",
213
+ "quote",
214
+ "syn",
215
+ ]
216
+
217
+ [[package]]
218
+ name = "pyo3-macros-backend"
219
+ version = "0.30.1"
220
+ source = "registry+https://github.com/rust-lang/crates.io-index"
221
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
222
+ dependencies = [
223
+ "heck",
224
+ "proc-macro2",
225
+ "quote",
226
+ "syn",
227
+ ]
228
+
229
+ [[package]]
230
+ name = "quote"
231
+ version = "1.0.47"
232
+ source = "registry+https://github.com/rust-lang/crates.io-index"
233
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
234
+ dependencies = [
235
+ "proc-macro2",
236
+ ]
237
+
238
+ [[package]]
239
+ name = "rawpointer"
240
+ version = "0.2.1"
241
+ source = "registry+https://github.com/rust-lang/crates.io-index"
242
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
243
+
244
+ [[package]]
245
+ name = "regex-automata"
246
+ version = "0.4.19"
247
+ source = "registry+https://github.com/rust-lang/crates.io-index"
248
+ checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
249
+ dependencies = [
250
+ "aho-corasick",
251
+ "memchr",
252
+ "regex-syntax",
253
+ ]
254
+
255
+ [[package]]
256
+ name = "regex-syntax"
257
+ version = "0.8.12"
258
+ source = "registry+https://github.com/rust-lang/crates.io-index"
259
+ checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
260
+
261
+ [[package]]
262
+ name = "roxmltree"
263
+ version = "0.21.2"
264
+ source = "registry+https://github.com/rust-lang/crates.io-index"
265
+ checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907"
266
+ dependencies = [
267
+ "memchr",
268
+ ]
269
+
270
+ [[package]]
271
+ name = "rustc-hash"
272
+ version = "2.1.3"
273
+ source = "registry+https://github.com/rust-lang/crates.io-index"
274
+ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
275
+
276
+ [[package]]
277
+ name = "syn"
278
+ version = "3.0.10"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
281
+ dependencies = [
282
+ "proc-macro2",
283
+ "quote",
284
+ "unicode-ident",
285
+ ]
286
+
287
+ [[package]]
288
+ name = "target-lexicon"
289
+ version = "0.13.6"
290
+ source = "registry+https://github.com/rust-lang/crates.io-index"
291
+ checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
292
+
293
+ [[package]]
294
+ name = "unicode-ident"
295
+ version = "1.0.27"
296
+ source = "registry+https://github.com/rust-lang/crates.io-index"
297
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
@@ -0,0 +1,21 @@
1
+ [package]
2
+ name = "datacut_native"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ publish = false
6
+ readme = "README.md"
7
+
8
+ [lib]
9
+ name = "datacut_native"
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ pyo3 = { version = "0.30", features = ["extension-module", "abi3-py39"] }
14
+ numpy = "0.30"
15
+ fancy-regex = "0.20"
16
+ roxmltree = "0.21"
17
+
18
+ [profile.release]
19
+ opt-level = 3
20
+ lto = true
21
+ codegen-units = 1
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: datacut-native
3
+ Version: 0.1.0
4
+ Requires-Dist: numpy
5
+ Summary: The Rust core of DataCut: SVG parsing and per-frame geometry
6
+ Author-email: Benjamín Ubilla <benjamin.ubilla@uc.cl>
7
+ License-Expression: MIT
8
+ Requires-Python: >=3.9
9
+ Project-URL: Source Code, https://github.com/MathItYT/datacut
@@ -0,0 +1,36 @@
1
+ # datacut_native
2
+
3
+ The Rust half of datacut, a Python extension built with [PyO3](https://pyo3.rs):
4
+
5
+ - `src/svg/`: the SVG parser datacut reads every SVG, Typst, LaTeX and text mobject
6
+ through (see `datacut/mobject/svg/svg_parse.py`). It computes exactly what
7
+ svgelements' `SVG.parse` did, to the last bit, which `tests/test_svg_parse.py` checks
8
+ against svgelements itself.
9
+ - `src/trace.rs`: tracing an SVG path into a VMobject's points.
10
+ - `src/lib.rs`: the per-frame geometry of mobjects (unit normals, subpath ranges,
11
+ scaling, rotation and shifting, and the family members `Mobject.become` carries over),
12
+ each checked against numpy on import (`datacut/utils/native.py`) and left unused if it
13
+ does not agree.
14
+ - `src/render.rs`: the order the renderer draws leaders in and the scissor rect a
15
+ post-processing effect is clipped to, checked the same way against
16
+ `datacut/utils/render_geometry.py`.
17
+
18
+ Everything here reproduces datacut's former Python and numpy results bit for bit; only
19
+ speed differs.
20
+
21
+ ## Building
22
+
23
+ Desktop (needs Rust):
24
+
25
+ uvx maturin build --release --out dist
26
+ uv pip install dist/datacut_native-*.whl
27
+
28
+ Browser (Pyodide; Linux or WSL, needs Rust and pyodide-build):
29
+
30
+ pip install pyodide-build
31
+ pyodide xbuildenv install 314.0.7
32
+ pyodide xbuildenv install-emscripten
33
+ bash build_pyodide.sh
34
+
35
+ `editor/browser_wasm/build_pyodide_wheels.sh` builds it along with the other browser
36
+ wheels, and the "Update browser wheels" GitHub Actions workflow runs that.
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bash
2
+ # Builds the datacut_native wheel for the browser (Pyodide), into native/dist.
3
+ #
4
+ # Needs, on Linux (WSL works): pyodide-build in an active Python of the same minor version
5
+ # as the Pyodide release, its cross-build environment, and the Emscripten it pins:
6
+ #
7
+ # pip install pyodide-build
8
+ # pyodide xbuildenv install <pyodide version>
9
+ # pyodide xbuildenv install-emscripten
10
+ #
11
+ # plus rustup, from which the Rust toolchain Pyodide asks for is installed below.
12
+ #
13
+ # NATIVE_VERSION, where set, is the version the wheel is built as (a fresh one per build keeps
14
+ # micropip from reusing an older wheel cached under the same URL).
15
+ set -euo pipefail
16
+
17
+ HERE="$(cd "$(dirname "$0")" && pwd)"
18
+ cd "$HERE"
19
+
20
+ if [[ -n "${NATIVE_VERSION:-}" ]]; then
21
+ cp pyproject.toml pyproject.toml.version-backup
22
+ trap 'mv pyproject.toml.version-backup pyproject.toml' EXIT
23
+ sed -i -E "s/^version = .*/version = \"$NATIVE_VERSION\"/" pyproject.toml
24
+ fi
25
+ rm -f "$HERE"/dist/datacut_native-*wasm32.whl
26
+
27
+ command -v pyodide >/dev/null 2>&1 || { echo "error: pyodide-build not found" >&2; exit 1; }
28
+
29
+ XBUILDENV_EMSDK="$(ls -d "$HOME"/.cache/pyodide-build/.pyodide-xbuildenv-*/*/emsdk 2>/dev/null | head -1)"
30
+ if ! command -v emcc >/dev/null 2>&1 && [[ -n "$XBUILDENV_EMSDK" ]]; then
31
+ # shellcheck disable=SC1091
32
+ source "$XBUILDENV_EMSDK/emsdk_env.sh" >/dev/null
33
+ fi
34
+ command -v emcc >/dev/null 2>&1 || { echo "error: emcc not found, run pyodide xbuildenv install-emscripten" >&2; exit 1; }
35
+
36
+ TOOLCHAIN="$(pyodide config get rust_toolchain)"
37
+ echo "==> Pyodide wants Emscripten $(pyodide config get emscripten_version), Rust $TOOLCHAIN"
38
+ rustup toolchain install "$TOOLCHAIN" --profile minimal
39
+ rustup target add --toolchain "$TOOLCHAIN" wasm32-unknown-emscripten
40
+ rustup component add --toolchain "$TOOLCHAIN" rust-src || true
41
+ export RUSTUP_TOOLCHAIN="$TOOLCHAIN"
42
+ # Kept apart from the native build's target directory, which may belong to another OS
43
+ export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$HOME/.cache/datacut-native-target}"
44
+
45
+ pyodide build --outdir "$HERE/dist"
46
+ ls -1 "$HERE"/dist/*emscripten*.whl
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.7,<2"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "datacut-native"
7
+ version = "0.1.0"
8
+ description = "The Rust core of DataCut: SVG parsing and per-frame geometry"
9
+ requires-python = ">=3.9"
10
+ dependencies = ["numpy"]
11
+ license = "MIT"
12
+ authors = [{ name = "Benjamín Ubilla", email = "benjamin.ubilla@uc.cl" }]
13
+
14
+ [project.urls]
15
+ "Source Code" = "https://github.com/MathItYT/datacut"
16
+
17
+ [tool.maturin]
18
+ module-name = "datacut_native"