-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
1117 lines (995 loc) · 58.7 KB
/
Package.swift
File metadata and controls
1117 lines (995 loc) · 58.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// swift-tools-version: 5.9
// python-ios-lib — Offline Python libraries for iOS/iPadOS
// https://github.com/yu314-coder/python-ios-lib
//
// In Xcode: File → Add Package Dependencies → paste:
// https://github.com/yu314-coder/python-ios-lib
// Then pick which packages you need. Dependencies auto-resolve.
import PackageDescription
let package = Package(
name: "python-ios-lib",
platforms: [.iOS(.v17)],
products: [
// ── Language interpreters (standalone, no Python runtime needed) ──
.library(name: "CInterpreter", targets: ["CInterpreter"]),
.library(name: "CppInterpreter", targets: ["CppInterpreter"]),
.library(name: "FortranInterpreter", targets: ["FortranInterpreter"]),
.library(name: "NumPy", targets: ["NumPy"]),
.library(name: "SymPy", targets: ["SymPy"]),
.library(name: "Plotly", targets: ["Plotly"]),
.library(name: "NetworkX", targets: ["NetworkX"]),
.library(name: "Pillow", targets: ["Pillow"]),
.library(name: "BeautifulSoup", targets: ["BeautifulSoup"]),
.library(name: "Requests", targets: ["Requests"]),
.library(name: "PyYAML", targets: ["PyYAML"]),
.library(name: "Rich", targets: ["Rich"]),
.library(name: "Tqdm", targets: ["Tqdm"]),
.library(name: "Click", targets: ["Click"]),
.library(name: "Cloup", targets: ["Cloup", "Click"]),
.library(name: "Mapbox_earcut", targets: ["Mapbox_earcut"]),
.library(name: "Isosurfaces", targets: ["Isosurfaces"]),
.library(name: "Markupsafe", targets: ["Markupsafe"]),
.library(name: "Jinja2", targets: ["Jinja2", "Markupsafe"]),
.library(name: "Screeninfo", targets: ["Screeninfo"]),
.library(name: "Watchdog", targets: ["Watchdog"]),
.library(name: "Fsspec", targets: ["Fsspec"]),
.library(name: "Moderngl", targets: ["Moderngl"]),
.library(name: "Moderngl_window", targets: ["Moderngl_window", "Moderngl"]),
.library(name: "Typing_extensions",targets: ["Typing_extensions"]),
.library(name: "Psutil", targets: ["Psutil"]),
.library(name: "Pygments", targets: ["Pygments"]),
.library(name: "Mpmath", targets: ["Mpmath"]),
.library(name: "Pydub", targets: ["Pydub"]),
.library(name: "JsonSchema", targets: ["JsonSchema"]),
.library(name: "CairoGraphics", targets: ["CairoGraphics"]),
.library(name: "FFmpegPyAV", targets: ["FFmpegPyAV"]),
.library(name: "Decorator", targets: ["Decorator"]),
.library(name: "PyWebView", targets: ["PyWebView"]),
// ── Small pure-Python utility libs (2026-05) ──
.library(name: "Dill", targets: ["Dill"]),
.library(name: "TinyDB", targets: ["TinyDB"]),
.library(name: "Plotext", targets: ["Plotext"]),
.library(name: "Wcwidth", targets: ["Wcwidth"]),
.library(name: "Ftfy", targets: ["Ftfy"]),
.library(name: "Pyparsing", targets: ["Pyparsing"]),
.library(name: "Periodictable", targets: ["Periodictable"]),
// ── Web frameworks + scientific extras (2026-05) ──
// Tropycal is standalone. Flask brings its full pure-Python
// stack so it actually runs (Werkzeug + Jinja2 + Markupsafe +
// Click). Dash bundles Flask + Plotly because that's the
// minimum that lets dash.Dash().run() serve a usable page.
// Streamlit lists PyArrow as a dep so SPM expresses the build
// graph correctly — but PyArrow is a placeholder target (no
// bundled binaries), so Streamlit's dataframe features error
// at runtime until someone cross-compiles Arrow C++ for iOS.
// See Sources/PyArrow/BUILD_INSTRUCTIONS.md.
.library(name: "Tropycal", targets: ["Tropycal"]),
.library(name: "Werkzeug", targets: ["Werkzeug"]),
.library(name: "Flask", targets: ["Flask", "Werkzeug", "Jinja2",
"Markupsafe", "Click"]),
.library(name: "Dash", targets: ["Dash", "Flask", "Werkzeug",
"Jinja2", "Markupsafe", "Click",
"Plotly"]),
.library(name: "PyArrow", targets: ["PyArrow"]),
.library(name: "Streamlit", targets: ["Streamlit", "Click", "Watchdog",
"Typing_extensions", "PyArrow",
"Tornado"]),
.library(name: "Tornado", targets: ["Tornado"]),
.library(name: "Xxhash", targets: ["Xxhash"]),
.library(name: "Rapidfuzz", targets: ["Rapidfuzz"]),
.library(name: "Levenshtein", targets: ["Levenshtein", "Rapidfuzz"]),
// Performance-accelerator block (added 2026-05-26):
.library(name: "Orjson", targets: ["Orjson"]), // fast JSON
.library(name: "Uvloop", targets: ["Uvloop"]), // fast asyncio
.library(name: "Ciso8601", targets: ["Ciso8601"]), // fast ISO date parse
.library(name: "Numexpr", targets: ["Numexpr"]), // fast NumPy expressions
.library(name: "Bottleneck", targets: ["Bottleneck"]), // fast NaN/rolling stats
// ── Multi-target umbrella products ──
// Each tick in Xcode's product picker adds EVERY listed target's
// framework + resource bundle to the consumer's project.pbxproj.
// Without these, SPM's `target.dependencies` only build them
// — Xcode never writes them into Frameworks/Libraries/Embedded
// Content, so the .app ships missing every transitive dep.
// (See https://forums.swift.org for "SPM transitive resources
// not embedded" — this is the standard workaround.)
// ── Requires NumPy ──
.library(name: "Sklearn", targets: ["Sklearn", "NumPy", "SciPy"]),
// SciPy auto-bundles its Fortran runtime (libfortran_io_stubs +
// libsf_error_state) as resources of the SciPy target itself,
// so this product needs no separate "ScipyRuntime" target.
.library(name: "SciPy", targets: ["SciPy", "NumPy"]),
// ── Requires Plotly ──
// Matplotlib now also pulls Dateutil (matplotlib/dates.py hard
// dep) so date-axis plots work for SwiftPM consumers.
.library(name: "Matplotlib", targets: ["Matplotlib", "Plotly", "Dateutil"]),
// python-dateutil — standalone product for consumers that want
// just the date utilities without the whole matplotlib stack.
.library(name: "Dateutil", targets: ["Dateutil"]),
// ── Data / IO / web stack (standalone products) ──
// Each lists every resource-bearing target it needs explicitly,
// because a consumer's .app only bundles the resource bundles of
// targets named in the product (matching how Manim lists NumPy,
// SciPy, … even though the Manim target also depends on them).
.library(name: "Pandas",
targets: ["Pandas", "NumPy", "Dateutil"]),
.library(name: "Openpyxl", targets: ["Openpyxl"]),
.library(name: "Httpx",
targets: ["Httpx", "Requests", "Typing_extensions"]),
.library(name: "Seaborn",
targets: ["Seaborn", "Matplotlib", "Plotly", "Pandas",
"NumPy", "SciPy", "Dateutil"]),
.library(name: "Statsmodels",
targets: ["Statsmodels", "Pandas", "NumPy", "SciPy",
"Dateutil"]),
.library(name: "Reportlab", targets: ["Reportlab", "Pillow"]),
.library(name: "Pypdf", targets: ["Pypdf"]),
.library(name: "Fpdf", targets: ["Fpdf", "Pillow"]),
.library(name: "Altair",
targets: ["Altair", "JsonSchema", "Jinja2", "Markupsafe",
"Typing_extensions"]),
// ── Utility + geospatial (standalone products) ──
.library(name: "Tabulate", targets: ["Tabulate"]),
.library(name: "PyJWT", targets: ["PyJWT"]),
.library(name: "Tenacity", targets: ["Tenacity"]),
.library(name: "Pendulum", targets: ["Pendulum"]),
.library(name: "MoreItertools", targets: ["MoreItertools"]),
.library(name: "SortedContainers", targets: ["SortedContainers"]),
.library(name: "Cachetools", targets: ["Cachetools"]),
.library(name: "Humanize", targets: ["Humanize"]),
.library(name: "Schedule", targets: ["Schedule"]),
.library(name: "Typer",
targets: ["Typer", "Click", "Rich", "Typing_extensions"]),
.library(name: "Lark", targets: ["Lark"]),
.library(name: "Textual",
targets: ["Textual", "Rich", "Typing_extensions"]),
.library(name: "XlsxWriter", targets: ["XlsxWriter"]),
.library(name: "Xarray",
targets: ["Xarray", "NumPy", "Pandas", "Dateutil"]),
.library(name: "Shapely", targets: ["Shapely", "NumPy"]),
.library(name: "Pyproj", targets: ["Pyproj"]),
.library(name: "Cartopy",
targets: ["Cartopy", "Shapely", "Pyproj", "Matplotlib",
"Plotly", "NumPy", "Dateutil"]),
// ── ML helpers / git / protocol / misc (standalone products) ──
.library(name: "Accelerate",
targets: ["Accelerate", "PyTorch", "Transformers",
"Tokenizers", "NumPy", "Psutil", "PyYAML"]),
.library(name: "Peft",
targets: ["Peft", "Accelerate", "PyTorch", "Transformers",
"Tokenizers", "NumPy", "Psutil", "PyYAML", "Tqdm"]),
/* GitPython removed: it shells out to the `git` binary via
* subprocess, which iOS does not support (no fork/exec, no git
* CLI) — `import git` fails with "[Errno 45] ios does not
* support processes". The gitdb/smmap object-store readers are
* pure-Python but only useful via GitPython, so the whole
* product is dropped rather than advertised as broken. */
.library(name: "Defusedxml", targets: ["Defusedxml"]),
.library(name: "Colorama", targets: ["Colorama"]),
.library(name: "Cattrs", targets: ["Cattrs"]),
.library(name: "Protobuf", targets: ["Protobuf"]),
.library(name: "Cffi", targets: ["Cffi"]),
.library(name: "Tinycss2", targets: ["Tinycss2"]),
.library(name: "Cssselect2", targets: ["Cssselect2", "Tinycss2"]),
.library(name: "Pydeck",
targets: ["Pydeck", "NumPy", "Jinja2", "Markupsafe"]),
// ── Requires multiple deps ──
// Manim covers the entire animation stack. Hard-imports at
// module load (every entry below crashes `import manim` if
// missing — traced from manim/__init__.py through
// utils/space_ops.py and _config):
// numpy, scipy, mapbox_earcut, cloup, click, rich, PIL,
// decorator
// Required by specific mobjects / features:
// matplotlib + plotly (plot mobjects)
// ffmpeg/pyav (Scene.render → mp4)
// cairo/pango/harfbuzz (manimpango text shaping)
// tqdm (render progress bar)
// latex (MathTex/Tex compile)
// pillow (image_mobject, camera, scene_file_writer)
// networkx (Graph mobject)
// pygments (Code mobject syntax highlighting)
// jinja2 (manim's HTML/SVG export templating)
// isosurfaces (3D surface plotting)
// screeninfo (camera defaults — multi-monitor query)
// watchdog (--auto-rerun file-watch mode)
// One tick → all 21 ride along.
.library(name: "Manim",
targets: ["Manim", "NumPy", "SciPy",
"Matplotlib", "Plotly",
"FFmpegPyAV", "CairoGraphics", "LaTeXEngine",
"Pillow", "Tqdm", "Rich", "Click", "Cloup",
"NetworkX", "Pygments", "SymPy", "Sklearn",
"Decorator", "Mapbox_earcut", "Isosurfaces",
"Jinja2", "Markupsafe", "FontTools", "Dateutil",
"Screeninfo", "Watchdog",
"Typing_extensions", "Psutil",
"Moderngl", "Moderngl_window",
"Pydub", "BeautifulSoup",
// ── Transitive runtime imports that were
// silently missing on SwiftPM consumers.
// Requests bundles urllib3/certifi/idna/
// charset_normalizer; without it any user code
// doing requests.get(...) ImportErrors at
// module load on the iOS target even though
// CodeBench shipped them in the bundled
// app_packages. Mpmath is a hard SymPy dep
// (arbitrary-precision math). PyYAML is read
// by manim's config loader. JsonSchema is
// required by Plotly + Jupyter for figure
// validation. Fsspec / Tornado are optional
// but pulled in by huggingface_hub and
// web-stack libs that manim users commonly
// combine with their scenes.
"Requests", "Mpmath", "PyYAML", "JsonSchema",
"Fsspec", "Tornado"]),
// LaTeXEngine renders SVG via cairo — bundle it together.
.library(name: "LaTeXEngine",
targets: ["LaTeXEngine", "CairoGraphics"]),
// ── Machine Learning: PyTorch + HuggingFace stack ──
.library(name: "PyTorch", targets: ["PyTorch"]),
.library(name: "Tokenizers", targets: ["Tokenizers"]),
.library(name: "Transformers",
targets: ["Transformers", "PyTorch", "Tokenizers"]),
// ── GPU acceleration on Apple Metal ──
// Also published as standalone repos:
// github.com/yu314-coder/cairometal (pycairo-compatible GPU cairo)
// github.com/yu314-coder/torchmetal (routes torch ops to Metal/MPS)
.library(name: "CairoMetal", targets: ["CairoMetal"]),
.library(name: "TorchMetal", targets: ["TorchMetal"]),
],
targets: [
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// STANDALONE — No dependencies
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// C interpreter (~3,661-line tree-walking interpreter, single C file).
// C89/C99/C23, 48 operators, structs, pointers, full preprocessor.
.target(
name: "CInterpreter",
path: "gcc",
sources: ["offlinai_cc.c"],
publicHeadersPath: "."
),
// C++ interpreter (~4,287 lines). Classes, STL, templates, inheritance.
.target(
name: "CppInterpreter",
path: "cpp",
sources: ["offlinai_cpp.c"],
publicHeadersPath: "."
),
// Fortran interpreter — ofort by Beliavsky (MIT, see
// third_party/ofort/LICENSE). ofort began as an extraction of this
// project's original interpreter and was matured upstream:
// type-bound procedures, fixed-form source, ~80+ intrinsics, a
// statistics module. The public ofort_* C API is unchanged.
.target(
name: "FortranInterpreter",
path: "third_party/ofort",
exclude: ["src/main.c", "src/ofort_c_api.c", "README.md", "LICENSE"],
sources: [
"src/ofort.c",
"src/ofort_values.c",
"src/ofort_fixed_form.c",
"src/ofort_stats.c",
],
publicHeadersPath: "include"
),
// NumPy 2.3.5 — native iOS build (arrays, linalg, FFT, random)
.target(name: "NumPy", path: "Sources/NumPy", resources: [.copy("numpy"),
.copy("numpy-2.3.5.post1.dist-info")]),
// SymPy 1.14 — symbolic math (pure Python)
.target(name: "SymPy", path: "Sources/SymPy", resources: [.copy("sympy"),
.copy("sympy-1.14.0.dist-info")]),
// Plotly 6.6 — interactive charts (pure Python).
// Bundles the sibling _plotly_utils package too — plotly's
// __init__.py imports from _plotly_utils.basevalidators et al.,
// which ships as a separate top-level package.
.target(name: "Plotly", path: "Sources/Plotly",
resources: [.copy("plotly"), .copy("_plotly_utils"),
.copy("plotly-6.6.0.dist-info")]),
// NetworkX 3.6 — graph theory (pure Python)
.target(name: "NetworkX", path: "Sources/NetworkX", resources: [.copy("networkx"),
.copy("networkx-3.6.1.dist-info")]),
// Pillow 12.2 — image processing (native iOS build)
.target(name: "Pillow", path: "Sources/Pillow", resources: [.copy("PIL"),
.copy("pillow-11.0.0.dist-info")]),
// BeautifulSoup4 — HTML/XML parsing (pure Python)
.target(name: "BeautifulSoup", path: "Sources/BeautifulSoup", resources: [.copy("bs4"),
.copy("beautifulsoup4-4.14.3.dist-info"),
.copy("bs4-4.14.3.dist-info"),
.copy("soupsieve-2.8.dist-info"),
.copy("soupsieve")]),
// requests — HTTP client (pure Python)
.target(name: "Requests", path: "Sources/Requests", resources: [.copy("requests"),
.copy("certifi-2026.2.25.dist-info"),
.copy("charset_normalizer-3.4.7.dist-info"),
.copy("idna-3.11.dist-info"),
.copy("requests-2.33.1.dist-info"),
.copy("urllib3-2.6.3.dist-info"),
.copy("charset_normalizer"),
.copy("certifi"),
.copy("idna"),
.copy("urllib3")]),
// PyYAML — YAML parser (native build)
.target(name: "PyYAML", path: "Sources/PyYAML", resources: [.copy("yaml"),
.copy("pyyaml-6.0.3.dist-info")]),
// rich — rich text, tables, progress bars (pure Python)
.target(name: "Rich", path: "Sources/Rich", resources: [.copy("rich"),
.copy("markdown_it_py-3.0.0.dist-info"),
.copy("mdurl-0.1.2.dist-info"),
.copy("rich-13.7.0.dist-info"),
.copy("markdown_it"),
.copy("mdurl")]),
// tqdm — progress bars (pure Python)
.target(name: "Tqdm", path: "Sources/Tqdm", resources: [.copy("tqdm"),
.copy("tqdm-4.67.3.dist-info")]),
// click — CLI framework (pure Python)
.target(name: "Click", path: "Sources/Click", resources: [.copy("click"),
.copy("click-8.1.7.dist-info")]),
// cloup — click extension (option groups, constraints, sub-command
// groups with section headers). Hard-imported by manim/_config at
// module load — without it `import manim` fails before any code
// runs. Pure Python, ~212 KB.
.target(name: "Cloup",
dependencies: ["Click"],
path: "Sources/Cloup",
resources: [.copy("cloup"),
.copy("cloup-3.0.5.dist-info")]),
// mapbox_earcut — polygon triangulation (164 KB, native .so).
// Hard-imported by manim/utils/space_ops.py at module load.
.target(name: "Mapbox_earcut", path: "Sources/Mapbox_earcut",
resources: [.copy("mapbox_earcut"),
.copy("mapbox_earcut-1.0.3.dist-info")]),
// isosurfaces — 3D surface algorithm. Hard-imported by manim's
// surface mobjects.
.target(name: "Isosurfaces", path: "Sources/Isosurfaces",
resources: [.copy("isosurfaces"),
.copy("isosurfaces-0.1.2.dist-info")]),
// markupsafe — XML/HTML escape utilities. Required by Jinja2
// (Jinja2 hard-imports `markupsafe` at module load).
.target(name: "Markupsafe", path: "Sources/Markupsafe",
resources: [.copy("markupsafe"),
.copy("markupsafe-3.0.3.dist-info")]),
// jinja2 — templating engine. Used by manim for its HTML/SVG
// export templates and by torch's inductor codegen path.
.target(name: "Jinja2",
dependencies: ["Markupsafe"],
path: "Sources/Jinja2",
resources: [.copy("jinja2"),
.copy("jinja2-3.1.6.dist-info")]),
// fontTools 4.60.2 — TTF/OTF parser + SVG path emitter. manimpango
// hard-imports `fontTools.ttLib.TTFont` and
// `fontTools.pens.svgPathPen.SVGPathPen` at module load to read
// installed fonts and rasterise per-codepoint vector paths for
// `Text` mobjects. Without this target SwiftPM consumers of the
// Manim product fall through to manimpango's "fontTools not
// available — minimal SVG fallback" branch (search
// `Sources/Manim/manimpango/__init__.py` for that string), which
// emits an empty SVG box where the text glyphs should be.
// No dist-info wheel — fontTools was source-installed, so we
// ship the package directory only.
.target(name: "FontTools", path: "Sources/FontTools",
resources: [.copy("fontTools")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// DATA / IO / WEB — pure-Python (+ self-contained Cython .so)
// stack. All package dirs are symlinks into app_packages
// (same pattern as Sources/Matplotlib/matplotlib) → ~0 added
// repo bytes. Each has a standalone library product below.
// None are forced into the Manim umbrella — manim doesn't
// import them; consumers tick the specific product they want.
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// pandas 2.2.3 — DataFrame / Series. 44 self-contained Cython
// .so (no external dylib deps, verified via otool). Needs numpy,
// python-dateutil, and a tz database — pytz is bundled here
// (pandas falls back to pytz when tzdata/zoneinfo is absent).
.target(name: "Pandas",
dependencies: ["NumPy", "Dateutil"],
path: "Sources/Pandas",
resources: [.copy("pandas"), .copy("pytz"),
.copy("pandas-2.2.3.dist-info")]),
// openpyxl — Excel .xlsx read/write (pandas' .read_excel /
// .to_excel backend). Needs et_xmlfile (bundled here). Ships as
// sourceless .pyc.
.target(name: "Openpyxl", path: "Sources/Openpyxl",
resources: [.copy("openpyxl"), .copy("et_xmlfile")]),
// httpx — modern sync/async HTTP client. Bundles its httpcore /
// h11 / anyio / sniffio stack. certifi + idna come from the
// Requests target dependency; anyio needs typing_extensions.
.target(name: "Httpx",
dependencies: ["Requests", "Typing_extensions"],
path: "Sources/Httpx",
resources: [.copy("httpx"), .copy("httpcore"), .copy("h11"),
.copy("anyio"), .copy("sniffio"),
.copy("httpcore-1.0.9.dist-info"), .copy("h11-0.16.0.dist-info")]),
// seaborn — statistical plotting on matplotlib. Pulls the whole
// matplotlib + pandas + scipy stack.
.target(name: "Seaborn",
dependencies: ["Matplotlib", "Pandas", "NumPy", "SciPy"],
path: "Sources/Seaborn",
resources: [.copy("seaborn")]),
// statsmodels 0.14.4 — regression / time-series / stats models.
// 26 self-contained Cython .so. Needs numpy + scipy + pandas +
// patsy (formula parser, bundled here).
.target(name: "Statsmodels",
dependencies: ["NumPy", "SciPy", "Pandas"],
path: "Sources/Statsmodels",
resources: [.copy("statsmodels"), .copy("patsy"),
.copy("statsmodels-0.14.4.dist-info"),
.copy("patsy-1.0.2.dist-info")]),
// reportlab — PDF generation. Uses Pillow for raster images.
.target(name: "Reportlab",
dependencies: ["Pillow"],
path: "Sources/Reportlab",
resources: [.copy("reportlab")]),
// pypdf — pure-Python PDF read / merge / split / encrypt.
.target(name: "Pypdf", path: "Sources/Pypdf",
resources: [.copy("pypdf")]),
// fpdf2 — simple PDF document generation. Uses Pillow for images.
.target(name: "Fpdf",
dependencies: ["Pillow"],
path: "Sources/Fpdf",
resources: [.copy("fpdf")]),
// altair — declarative (Vega-Lite) charting. Needs jsonschema
// (figure validation), jinja2 (HTML export), narwhals (dataframe
// compat, bundled here), typing_extensions.
.target(name: "Altair",
dependencies: ["JsonSchema", "Jinja2", "Typing_extensions"],
path: "Sources/Altair",
resources: [.copy("altair"), .copy("narwhals"),
.copy("altair-6.0.0.dist-info"),
.copy("narwhals-1.16.0.dist-info")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// UTILITY + GEOSPATIAL tier — all symlinks into app_packages
// (~0 added repo bytes). Standalone products below; none in the
// Manim umbrella. Sub-deps (shellingham/platformdirs/shapefile)
// are bundled inline into the target that needs them.
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
.target(name: "Tabulate", path: "Sources/Tabulate",
resources: [.copy("tabulate")]),
// PyJWT — JSON Web Token encode/decode (module name `jwt`).
.target(name: "PyJWT", path: "Sources/PyJWT",
resources: [.copy("jwt")]),
.target(name: "Tenacity", path: "Sources/Tenacity",
resources: [.copy("tenacity"), .copy("tenacity-9.1.2.dist-info")]),
.target(name: "Pendulum", path: "Sources/Pendulum",
resources: [.copy("pendulum")]),
.target(name: "MoreItertools", path: "Sources/MoreItertools",
resources: [.copy("more_itertools")]),
.target(name: "SortedContainers", path: "Sources/SortedContainers",
resources: [.copy("sortedcontainers")]),
.target(name: "Cachetools", path: "Sources/Cachetools",
resources: [.copy("cachetools"), .copy("cachetools-6.2.6.dist-info")]),
.target(name: "Humanize", path: "Sources/Humanize",
resources: [.copy("humanize")]),
.target(name: "Schedule", path: "Sources/Schedule",
resources: [.copy("schedule"), .copy("schedule-1.2.2.dist-info")]),
// typer — CLI framework. Bundles shellingham (shell detection);
// depends on Click + Rich + Typing_extensions.
.target(name: "Typer",
dependencies: ["Click", "Rich", "Typing_extensions"],
path: "Sources/Typer",
resources: [.copy("typer"), .copy("shellingham")]),
.target(name: "Lark", path: "Sources/Lark",
resources: [.copy("lark")]),
// textual — TUI framework. Bundles platformdirs; depends on Rich
// (+ markdown_it, which Rich already ships) + Typing_extensions.
.target(name: "Textual",
dependencies: ["Rich", "Typing_extensions"],
path: "Sources/Textual",
resources: [.copy("textual"), .copy("platformdirs"),
.copy("textual-0.89.1.dist-info")]),
.target(name: "XlsxWriter", path: "Sources/XlsxWriter",
resources: [.copy("xlsxwriter")]),
// xarray — N-D labeled arrays. Needs numpy + pandas.
.target(name: "Xarray",
dependencies: ["NumPy", "Pandas"],
path: "Sources/Xarray",
resources: [.copy("xarray"), .copy("xarray-2024.7.0.dist-info")]),
// shapely 2.0.6 — geometry. 3 Cython .so with GEOS statically
// linked (verified self-contained via otool). Needs numpy.
.target(name: "Shapely",
dependencies: ["NumPy"],
path: "Sources/Shapely",
resources: [.copy("shapely"), .copy("shapely-2.0.6.dist-info")]),
// pyproj 3.6.1 — cartographic projections. PROJ statically
// linked into the .so; carries its own ~9 MB PROJ data dir
// (proj_dir/share/proj/proj.db) which it reads at runtime.
.target(name: "Pyproj", path: "Sources/Pyproj",
resources: [.copy("pyproj"), .copy("pyproj-3.6.1.dist-info")]),
// cartopy — geospatial mapping on matplotlib. Bundles pyshp
// (shapefile.py); depends on Shapely + Pyproj + Matplotlib + NumPy.
.target(name: "Cartopy",
dependencies: ["Shapely", "Pyproj", "Matplotlib", "NumPy"],
path: "Sources/Cartopy",
resources: [.copy("cartopy"), .copy("shapefile.py"),
.copy("pyshp-3.0.8.dist-info")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ML helpers / git / protocol / misc — all symlinks into
// app_packages (~0 added repo bytes). Standalone products below.
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// accelerate — HF device placement / mixed precision / launch.
// Pulls the torch + transformers stack; bundles `packaging`
// inline (no standalone Packaging target). huggingface_hub /
// safetensors / filelock come from the Transformers dependency.
.target(name: "Accelerate",
dependencies: ["PyTorch", "Transformers", "NumPy",
"Psutil", "PyYAML"],
path: "Sources/Accelerate",
resources: [.copy("accelerate"), .copy("packaging"),
.copy("accelerate-0.30.1.dist-info")]),
// peft — parameter-efficient fine-tuning (LoRA etc.).
.target(name: "Peft",
dependencies: ["Accelerate", "Transformers", "PyTorch",
"NumPy", "Tqdm"],
path: "Sources/Peft",
resources: [.copy("peft"), .copy("peft-0.12.0.dist-info")]),
/* (GitPython target removed — subprocess-based, non-functional on
* iOS. See the commented-out library product above.) */
// defusedxml — XML bomb / entity-expansion hardening.
.target(name: "Defusedxml", path: "Sources/Defusedxml",
resources: [.copy("defusedxml")]),
// colorama — cross-platform terminal color codes.
.target(name: "Colorama", path: "Sources/Colorama",
resources: [.copy("colorama")]),
// cattrs — structured (de)serialization on top of attrs. Bundles
// attr + attrs (their runtime).
.target(name: "Cattrs", path: "Sources/Cattrs",
resources: [.copy("cattrs"), .copy("attr"), .copy("attrs"),
.copy("attrs-24.2.0.dist-info")]),
// protobuf — Google Protocol Buffers (module `google.protobuf`,
// pure-Python implementation).
.target(name: "Protobuf", path: "Sources/Protobuf",
resources: [.copy("google"),
.copy("protobuf-5.29.6.dist-info")]),
// cffi — C FFI for Python. Bundles its _cffi_backend extension
// (self-contained; the /tmp install-name is cosmetic for a
// dlopen'd module).
.target(name: "Cffi", path: "Sources/Cffi",
resources: [.copy("cffi"),
.copy("_cffi_backend.cpython-314-iphoneos.so"),
.copy("cffi-1.17.1.dist-info")]),
// tinycss2 — low-level CSS parser. Bundles webencodings (its dep).
.target(name: "Tinycss2", path: "Sources/Tinycss2",
resources: [.copy("tinycss2"), .copy("webencodings"),
.copy("tinycss2-1.4.0.dist-info"),
.copy("webencodings-0.5.1.dist-info")]),
// cssselect2 — CSS selector matching for ElementTree. Needs tinycss2.
.target(name: "Cssselect2",
dependencies: ["Tinycss2"],
path: "Sources/Cssselect2",
resources: [.copy("cssselect2"),
.copy("cssselect2-0.8.0.dist-info")]),
// pydeck — deck.gl bindings (the ~23 MB is prebuilt deck.gl JS
// served as static assets). Hard-imports numpy (bindings/layer.py)
// + jinja2 (HTML export); the ipywidgets Jupyter widget is a
// separate lazy module, so core `import pydeck` works without it.
.target(name: "Pydeck",
dependencies: ["NumPy", "Jinja2"],
path: "Sources/Pydeck",
resources: [.copy("pydeck"), .copy("pydeck-0.9.2.dist-info")]),
// screeninfo — multi-monitor query. manim's camera reads this
// to decide default frame size if not configured.
.target(name: "Screeninfo", path: "Sources/Screeninfo",
resources: [.copy("screeninfo"),
.copy("screeninfo-0.8.1.dist-info")]),
// watchdog — file-system event observer. Used by manim's
// --auto-rerun and `manim render` hot-reload modes.
.target(name: "Watchdog", path: "Sources/Watchdog",
resources: [.copy("watchdog"),
.copy("watchdog-4.0.0.dist-info")]),
// fsspec — filesystem-spec abstraction. Required by torch's
// distributed checkpoint loaders + huggingface_hub's downloads.
.target(name: "Fsspec", path: "Sources/Fsspec",
resources: [.copy("fsspec"),
.copy("fsspec-2026.3.0.dist-info")]),
// Pygments — syntax highlighting (pure Python)
.target(name: "Pygments", path: "Sources/Pygments", resources: [.copy("pygments"),
.copy("pygments-2.18.0.dist-info")]),
// mpmath — arbitrary precision math (pure Python)
.target(name: "Mpmath", path: "Sources/Mpmath", resources: [.copy("mpmath"),
.copy("mpmath-1.4.1.dist-info")]),
// pydub — audio manipulation (pure Python)
.target(name: "Pydub", path: "Sources/Pydub", resources: [.copy("pydub"),
.copy("audioop_lts-0.2.1.dist-info"),
.copy("pydub-0.25.1.dist-info"),
.copy("audioop")]),
// jsonschema — JSON validation (pure Python)
.target(name: "JsonSchema", path: "Sources/JsonSchema", resources: [.copy("jsonschema"),
.copy("attr-24.2.0.dist-info"),
.copy("attrs-24.2.0.dist-info"),
.copy("jsonschema-4.26.0.dist-info"),
.copy("jsonschema_specifications-2024.10.1.dist-info"),
.copy("referencing-0.36.2.dist-info"),
.copy("rpds_py-0.22.3.dist-info"),
.copy("attr"),
.copy("attrs"),
.copy("referencing"),
.copy("rpds"),
.copy("jsonschema_specifications")]),
// decorator — Michele Simionato's full `decorator` package (5.3.1),
// pure Python. Full API (decorate / decorator / contextmanager /
// dispatch_on) — upgraded from the old minimal shim.
.target(name: "Decorator", path: "Sources/Decorator", resources: [.copy("decorator"),
.copy("decorator-5.3.1.dist-info")]),
// ── Small pure-Python utility libs (2026-05) ──
// dill — extended pickling (closures, lambdas, sessions). Pure Python.
.target(name: "Dill", path: "Sources/Dill", resources: [.copy("dill"),
.copy("dill-0.4.1.dist-info")]),
// tinydb — zero-dependency JSON document DB. Pure Python.
.target(name: "TinyDB", path: "Sources/TinyDB", resources: [.copy("tinydb"),
.copy("tinydb-4.8.2.dist-info")]),
// plotext — plots in the terminal (no matplotlib). Pure Python.
.target(name: "Plotext", path: "Sources/Plotext", resources: [.copy("plotext"),
.copy("plotext-5.3.2.dist-info")]),
// wcwidth — terminal cell-width of unicode chars (ftfy dep). Pure Python.
.target(name: "Wcwidth", path: "Sources/Wcwidth", resources: [.copy("wcwidth"),
.copy("wcwidth-0.7.0.dist-info")]),
// ftfy — fixes mojibake / broken unicode text. Pure Python.
.target(name: "Ftfy", dependencies: ["Wcwidth"], path: "Sources/Ftfy", resources: [.copy("ftfy"),
.copy("ftfy-6.3.1.dist-info")]),
// pyparsing — grammar parsing (periodictable dep). Pure Python.
.target(name: "Pyparsing", path: "Sources/Pyparsing", resources: [.copy("pyparsing"),
.copy("pyparsing-3.3.2.dist-info")]),
// periodictable — chemistry element/isotope data. Pure Python (+ NumPy).
.target(name: "Periodictable", dependencies: ["NumPy", "Pyparsing"], path: "Sources/Periodictable", resources: [.copy("periodictable"),
.copy("periodictable-2.1.0.dist-info")]),
// pywebview — CodeBench shim of pywebview that routes
// create_window/load_url/load_html into the host app's preview
// pane via file-IPC instead of spawning a real native window
// (which iOS forbids). Pure Python.
.target(name: "PyWebView", path: "Sources/PyWebView", resources: [.copy("webview"),
.copy("pywebview-5.4.0.dist-info")]),
// pycairo Python bindings to cairo. Ships the full Python module
// (cairo/__init__.py + _cairo.cpython-314-iphoneos.so), which
// statically links libcairo + libpixman + libfreetype + libfribidi
// into the .so. So `import cairo` gives the full Pythonic API
// (cairo.LineJoin, cairo.LineCap, cairo.Context, …) without
// needing any separate libcairo.dylib at runtime.
//
// pango / harfbuzz come along inside manimpango's own .so files
// (manimpango is shipped via the Manim target). We don't ship
// them as separate Python modules because there's no pycairo-
// style Python binding for them — they're consumed via manimpango
// and via cairo's text APIs.
.target(name: "CairoGraphics", path: "Sources/CairoGraphics",
resources: [.copy("cairo"),
.copy("pycairo-1.29.0.dist-info")]),
// FFmpeg 62 + PyAV — video encoding/decoding (native iOS, 7 dylibs)
.target(name: "FFmpegPyAV", path: "Sources/FFmpegPyAV", resources: [.copy("ffmpeg"), .copy("av"),
.copy("av-17.0.1.dist-info")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// REQUIRES NUMPY — auto-included when you select these
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// scikit-learn — ML (40 modules). Needs: NumPy
.target(name: "Sklearn", dependencies: ["NumPy"], path: "Sources/Sklearn", resources: [.copy("sklearn"),
.copy("scikit_learn-1.8.0.dist-info")]),
// SciPy — scientific computing. Needs: NumPy.
// Bundles libfortran_io_stubs.dylib + libsf_error_state.dylib
// (Fortran runtime for scipy's BLAS/LAPACK/sparse paths). Without
// these, `import scipy.spatial` / `scipy.sparse` / `scipy.linalg`
// crash at load with "symbol not found".
.target(name: "SciPy",
dependencies: ["NumPy"],
path: "Sources/SciPy",
resources: [.copy("scipy"), .copy("scipy_runtime"),
.copy("scipy-1.15.0.dist-info")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// REQUIRES PLOTLY
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// matplotlib — Plotly backend (64 modules). Needs: Plotly
.target(name: "Matplotlib", dependencies: ["Plotly", "Dateutil"], path: "Sources/Matplotlib", resources: [.copy("matplotlib"),
.copy("matplotlib-3.9.0.dist-info"),
.copy("narwhals-1.16.0.dist-info"),
.copy("packaging-26.0.dist-info"),
.copy("narwhals"),
.copy("packaging"),
// cycler is a hard matplotlib import (matplotlib/rcsetup.py →
// `from cycler import Cycler, cycler`). It was bundled in
// app_packages but never copied into this target, so SVM
// consumers ImportError'd at `import matplotlib`. dateutil
// (the other missing hard dep, used by matplotlib/dates.py)
// comes in via the Dateutil target dependency above.
.copy("cycler"),
.copy("mpl_toolkits")]),
// python-dateutil 2.x — date parsing / recurrence rules. A hard
// import of matplotlib (matplotlib/dates.py → `from dateutil.rrule
// import rrule`) AND pandas (pandas/_libs/tslibs needs it) AND a
// long tail of other libraries. Ships partly as sourceless .pyc;
// its `six` shim lives as a top-level six.pyc, bundled here too
// (dateutil/rrule.py → `from six import advance_iterator`).
// Shared target so matplotlib + pandas don't each duplicate it.
// The package dirs are symlinks into app_packages (same pattern
// as Sources/Matplotlib/matplotlib) → ~0 added repo bytes.
.target(name: "Dateutil", path: "Sources/Dateutil",
resources: [.copy("dateutil"), .copy("six.pyc")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// REQUIRES MULTIPLE DEPS — all auto-included
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// manim — math animations.
// Needs: NumPy + Matplotlib + FFmpeg + Cairo + LaTeXEngine.
// (LaTeXEngine is required because manim's `Tex` / `MathTex`
// mobjects shell out to pdflatex via offlinai_latex, which is
// the bridge target inside LaTeXEngine. Without it those
// mobjects raise "pdflatex not found" at runtime.)
// Adding `Manim` as a SwiftPM product dependency auto-includes
// every transitive resource bundle below — Xcode's Product
// Picker only needs Manim ticked.
.target(name: "Manim",
dependencies: ["NumPy", "SciPy",
"Matplotlib", "FFmpegPyAV",
"CairoGraphics", "LaTeXEngine",
"Pillow", "Tqdm", "Rich", "Click", "Cloup",
"NetworkX", "Pygments", "SymPy", "Sklearn",
"Decorator", "Mapbox_earcut", "Isosurfaces",
"Jinja2", "FontTools", "Dateutil",
"Screeninfo", "Watchdog",
"Typing_extensions", "Psutil",
"Moderngl", "Moderngl_window",
"Pydub", "BeautifulSoup"],
path: "Sources/Manim",
resources: [
.copy("manim"), .copy("manimpango"), .copy("offlinai_latex"),
.copy("svgelements"), .copy("pathops"),
.copy("srt.py"), // single-file pkg, manim/scene/scene.py imports it
.copy("manim-0.19.0.dist-info"),
.copy("manimpango-0.6.1.dist-info"),
.copy("offlinai_latex-1.0.1.dist-info"),
.copy("skia_pathops-0.9.2.dist-info"),
.copy("svgelements-1.9.6.dist-info"),
.copy("srt-3.5.3.dist-info"),
]),
// LaTeX engine — pdftex + texmf. Needs: Cairo
.target(name: "LaTeXEngine", dependencies: ["CairoGraphics"], path: "Sources/LaTeXEngine", resources: [.copy("latex")]),
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MACHINE LEARNING — PyTorch + HuggingFace stack
// (native iOS arm64 — first public build of each on iOS)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// PyTorch 2.1.2 — full `import torch` on iPad (tensors, autograd,
// nn, optim, JIT). 95/95 numerical + training correctness asserts.
// libtorch_python.dylib (99 MB) ships via Git LFS.
// typing_extensions.py: `torch.serialization`, `torch.optim`, onnx
// exporter, etc. all `from typing_extensions import ...` at module
// load — BeeWare's stdlib doesn't ship it so we bundle it alongside.
.target(
name: "PyTorch",
path: "Sources/PyTorch",
resources: [
.copy("torch"),
.copy("regex"),
.copy("typing_extensions.py"),
// libtorch_python.dylib (103MB) ships as an LZMA blob
// because GitHub rejects raw blobs over 100MB and Git
// LFS is incompatible with SwiftPM's checkout machinery.
// Materialized to ~/Library/Caches at first use via
// PyTorchLib.bootstrap() — see PyTorch.swift.
.copy("torch_dylib"),
.copy("regex-2024.11.6.dist-info"),
.copy("torch-2.1.0.dist-info"),
.copy("typing_extensions-4.15.0.dist-info"),
]
),
// tokenizers 0.19.1 — HuggingFace's Rust tokenizers, cross-compiled
// for iOS arm64 (first public iOS build). BPE/WordPiece/Unigram
// trainers + fast tokenizers via PyO3.
.target(
name: "Tokenizers",
path: "Sources/Tokenizers",
resources: [.copy("tokenizers"),
.copy("tokenizers-0.19.1.dist-info")]
),
// moderngl — OpenGL bindings (alternative renderer to Cairo).
// Only loaded by manim.renderer.opengl_renderer; lazy-imported.
.target(name: "Moderngl", path: "Sources/Moderngl",
resources: [.copy("moderngl")]),
// moderngl_window — windowing layer for moderngl. Lazy-imported.
.target(name: "Moderngl_window", path: "Sources/Moderngl_window",
resources: [.copy("moderngl_window")]),
// typing_extensions — backports of typing features. Many libs
// (huggingface_hub, narwhals, pydantic-style codebases) hard-import
// this at module load.
.target(name: "Typing_extensions", path: "Sources/Typing_extensions",
resources: [.copy("typing_extensions.py")]),
// psutil — process/system info. Used by manim's render-pipeline
// memory-tracking and by transformers' device introspection.
.target(name: "Psutil", path: "Sources/Psutil",
resources: [.copy("psutil")]),
// transformers 4.41.2 — HuggingFace models (BERT, GPT-2, T5, BART).
// Construct + train + generate + save/load on-device. Needs: PyTorch + Tokenizers.
.target(
name: "Transformers",
dependencies: ["PyTorch", "Tokenizers"],
path: "Sources/Transformers",
resources: [
.copy("transformers"),
.copy("huggingface_hub"),
.copy("filelock"),
.copy("safetensors"),
.copy("filelock-3.28.0.dist-info"),
.copy("huggingface_hub-0.24.7.dist-info"),
.copy("safetensors-0.4.5.dist-info"),
.copy("transformers-4.41.2.dist-info"),
]
),
// ─── New 2026-05 additions: web/data-app stacks ───────────────
// tropycal 1.4 — tropical cyclone analysis (HURDAT2, IBTrACS,
// climo statistics, storm-track utilities). Pure Python; the
// map-plotting features need cartopy which isn't bundled, but
// every data-analysis API works without it.
.target(name: "Tropycal", path: "Sources/Tropycal",
resources: [.copy("tropycal"),
.copy("tropycal-1.4.dist-info")]),
// werkzeug 3.1 — WSGI utility layer; Flask's HTTP plumbing.
// Pure Python.
.target(name: "Werkzeug", path: "Sources/Werkzeug",
resources: [.copy("werkzeug"),
.copy("werkzeug-3.1.8.dist-info")]),
// flask 3.1 — web microframework. Pure Python. Listed deps
// (Werkzeug / Jinja2 / Markupsafe / Click) are SPM dependencies
// so they end up linked into anything that depends on Flask.
.target(name: "Flask",
dependencies: ["Werkzeug", "Jinja2", "Markupsafe", "Click"],
path: "Sources/Flask",
resources: [.copy("flask"),
// Flask 3.x hard-imports both at module load
// (blinker → flask.signals, itsdangerous →
// session cookie signing). They were bundled
// in app_packages but never copied here, so
// `import flask` ImportError'd for SwiftPM
// consumers. Same gap as matplotlib/dateutil.
.copy("blinker"),
.copy("itsdangerous"),
.copy("blinker-1.9.0.dist-info"),
.copy("itsdangerous-2.2.0.dist-info"),
.copy("flask-3.1.3.dist-info")]),
// dash 4.1 — Plotly's reactive web framework. Pure Python.
// The ~28 MB this adds is the prebuilt JS for dash-html-
// components and dash-core-components that ships inside the
// wheel; we can't strip it because Dash serves these as
// static assets at runtime.
.target(name: "Dash",
dependencies: ["Flask", "Plotly"],
path: "Sources/Dash",
resources: [.copy("dash"),
.copy("dash-4.1.0.dist-info")]),
// pyarrow 15.0.2 — cross-compiled for iOS arm64. The actual
// tree is deployed via app_packages/site-packages/pyarrow/
// rather than through the SPM resource bundle. Reason: when
// SPM copies pyarrow's .so files into a Bundle.module, Xcode
// promotes each one into a `*.framework/` wrapper directory,
// which BREAKS `@rpath/libarrow_python.dylib` resolution —
// dyld looks for the dylib inside the wrapper instead of
// next to the .so where it actually sits.
//
// Living in app_packages/site-packages/ keeps the original
// `.so + .dylib` colocated, so `@loader_path` resolves cleanly.
// The SPM target is kept (as a Swift-only stub) so consumers
// can still depend on it for the version stamp / namespace.
//
// To rebuild or extend (parquet, dataset, etc.) see
// Sources/PyArrow/BUILD_INSTRUCTIONS.md.
.target(name: "PyArrow", path: "Sources/PyArrow"),
// streamlit 1.50 — data-app framework. Universal wheel; the
// 23 MB of static/ is the prebuilt React frontend it serves.
// Listed deps cover the pure-Python ones we already ship; the
// heavy hitters (numpy/pandas/pillow/rich/requests) the user
// ticks separately in Xcode since they're shared widely.
// PyArrow dep is intentional: streamlit's import will error
// clearly on iOS until the user supplies a real Arrow build.
.target(name: "Streamlit",
dependencies: ["Click", "Watchdog", "Typing_extensions",
"PyArrow", "Tornado"],
path: "Sources/Streamlit",
resources: [.copy("streamlit"),
.copy("streamlit-1.50.0.dist-info")]),
// tornado 6.5 — async HTTP / websocket framework, required by
// streamlit. The shipped wheel includes one optional C
// extension (tornado.speedups) for websocket-mask SIMD; we
// strip the .so on deploy because (a) it's a macOS Mach-O and
// would fail to load on iOS, and (b) tornado has a pure-Python
// fallback wrapped in try/except ImportError. Perf hit is