This repository was archived by the owner on Apr 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
1787 lines (1606 loc) · 94.1 KB
/
Makefile
File metadata and controls
1787 lines (1606 loc) · 94.1 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
SHELL:=/usr/bin/bash
# Check that CC is wasixcc, works, and binfmt is setup correctly
ifeq ($(MAKELEVEL),0)
ifndef SKIP_CC_CHECK
# CC must contain wasixcc
$(if $(findstring wasixcc,$(CC)),,\
$(error CC must contain "wasixcc" (got "$(CC)")))
# CC must be able to compile and run a binary
_cc_test := $(shell \
tmpdir="$$(mktemp -d -t cc-test.XXXXXX)"; \
tmp="$$tmpdir/cc-test.wasm"; \
export SOURCE_DATE_EPOCH=1; \
echo 'int main(){return 0;}' | \
$(CC) -frandom-seed=0 -g0 -x c -o "$$tmp" - >/dev/null 2>/dev/tty && \
"$$tmp" >/dev/null 2>/dev/tty && \
rm -rf "$$tmpdir" && echo ok || \
{ rm -rf "$$tmpdir"; exit 1; })
$(if $(_cc_test),,\
$(error CC cannot compile and run a test program. Make sure that a wasixcc cross-env is activated and binfmt is not set to an outdated wasmer version.))
endif # SKIP_CC_CHECK
endif # MAKELEVEL == 0
PWD:=$(shell pwd)
PYTHON_WASIX_BINARIES:=${PWD}/python-wasix-binaries
MESON_CROSSFILE=${PWD}/resources/wasi.meson.cross
BAZEL_TOOLCHAIN=${PWD}/resources/bazel-toolchain
CMAKE_TOOLCHAIN=${PWD}/resources/wasix-toolchain.cmake
PATCH_DIR=${PWD}/patches
GIT:=git -c 'user.name=build-scripts' -c 'user.email=wasix@wasmer.io' -c 'init.defaultBranch=main'
WASMER ?= wasmer
ENV_VARS_FOR_NATIVE_CC=CC=/usr/bin/clang CXX=/usr/bin/clang++
ENV_VARS_FOR_NATIVE_TOOLS=${ENV_VARS_FOR_NATIVE_CC} LD=/usr/bin/ld AR=/usr/bin/ar AS=/usr/bin/as
# You should only run this Makefile with -j1, because git does not like parallel submodule operations
JOBS=12
# Install libs to the normal sysroot if not specified otherwise
LIBS_DESTDIR?=${WASIXCC_SYSROOT}
# Install python wheels here
WHEELS_DESTDIR?=""
# Wheels build a .whl file
WHEELS=
WHEELS+=numpy
WHEELS+=pytz
WHEELS+=markupsafe
# Not a native package at all
WHEELS+=dateutil
# Technically not a native package, but it uses a native build process to prepare some files.
WHEELS+=tzdata
WHEELS+=pandas
WHEELS+=six
WHEELS+=msgpack-python
WHEELS+=pycryptodome
WHEELS+=pycryptodomex
WHEELS+=pyzbar
WHEELS+=cython
WHEELS+=pypandoc
WHEELS+=pypandoc_binary
WHEELS+=psycopg
WHEELS+=psycopg-pool
WHEELS+=psycopg-binary
WHEELS+=brotlicffi
WHEELS+=cffi
WHEELS+=pillow
WHEELS+=uvloop
WHEELS+=mysqlclient
WHEELS+=python-qrcode
WHEELS+=pycparser
WHEELS+=pydantic
WHEELS+=typing_extensions
WHEELS+=typing-inspection
WHEELS+=annotated-types
WHEELS+=shapely
WHEELS+=regex
WHEELS+=lxml
WHEELS+=protobuf
# TODO: Currently requires libcares2 to be installed natively. This is not ideal, but I don't have the time to debug this right now.
# Maybe it's also python3-cares or python3-grpcio
# Ok it does not seem to be any of those. I disable this for now as it only build on my laptop
WHEELS+=grpc
WHEELS+=numpy1
WHEELS+=numpy2-0-2
WHEELS+=numpy2-3-2
WHEELS+=python-crc32c
WHEELS+=requests
WHEELS+=urllib3
WHEELS+=idna
WHEELS+=certifi
WHEELS+=charset_normalizer
WHEELS+=pypng
WHEELS+=pyarrow
WHEELS+=pyarrow19-0-1
WHEELS+=matplotlib
WHEELS+=packaging
WHEELS+=pyparsing
WHEELS+=cycler
WHEELS+=kiwisolver
WHEELS+=contourpy
WHEELS+=pycurl
WHEELS+=pyopenssl
WHEELS+=aspw
WHEELS+=zstandard
WHEELS+=caio
WHEELS+=jqpy
WHEELS+=python-xxhash
WHEELS+=peewee
WHEELS+=clickhouse-connect
WHEELS+=pandas2-2-3
WHEELS+=python-lz4
WHEELS+=fastavro
WHEELS+=greenlet
WHEELS+=sqlalchemy
WHEELS+=eventlet
WHEELS+=greenback
WHEELS+=outcome
WHEELS+=attrs
WHEELS+=sniffio
WHEELS+=zope_interface
WHEELS+=zope_event
WHEELS+=dnspython
WHEELS+=gevent
WHEELS+=multidict
WHEELS+=yarl
WHEELS+=propcache
WHEELS+=aiohappyeyeballs
WHEELS+=aiosignal
WHEELS+=frozenlist
WHEELS+=async-timeout
WHEELS+=aiojobs
WHEELS+=aioresponses
WHEELS+=bytecode
WHEELS+=aiohttp
WHEELS+=cryptography
WHEELS+=cryptography43-0-3
WHEELS+=bcrypt
# WHEELS_END
##### List of all wheel in python-wasix-binaries with reasons for inclusion in here #####
#
# Use the following command to list all new wheels in the python-wasix-binaries repository:
#
# diff <(git ls-tree 531b962aae070e058138c17614f8cbe3e2607d72:wheels | grep -Po '[^\t ]*.whl') <(git ls-tree HEAD:wheels | grep -Po '[^\t ]*.whl') | grep '^>' | cut -d' ' -f2 | sort
#
# Don't forget to update the commit hash above afterwards!
PYTHON_WASIX_BINARIES_WHEELS=
# Included: Not moved to build-scripts yet
# TODO: Included in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=aiohttp-3.12.4-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=cffi-1.17.1-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
# PYTHON_WASIX_BINARIES_WHEELS+=cryptography-45.0.4-cp313-abi3-wasix_wasm32
# Not included: Source build in build-scripts
# PYTHON_WASIX_BINARIES_WHEELS+=cryptography-43.0.3-cp313-abi3-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=dateutil-cp313-cp313-wasix_wasm32
# Included: Not moved to build-scripts yet
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=ddtrace-3.10.2-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
# PYTHON_WASIX_BINARIES_WHEELS+=google_crc32c-1.7.1-py3-none-any
# Included: Not moved to build-scripts yet
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=httptools-0.6.4-cp313-cp313-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=jiter-0.10.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=lxml-6.0.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=markupsafe-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=msgpack-1.1.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=mysqlclient-2.2.7-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=numpy-wasix-cp313-cp313-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=orjson-3.11.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=pandas-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=peewee-3.18.2-cp313-cp313-wasix_wasm32
# Included: Build in build-script requires minor fixes to allow bundeling libpq
PYTHON_WASIX_BINARIES_WHEELS+=psycopg-3.2.9-py3-none-any
# Not included: Need to figure out the difference between that and psycopg_binary again
# PYTHON_WASIX_BINARIES_WHEELS+=psycopg_c-3.2.9-cp313-cp313-wasix_wasm32
# Included: Build in build-script requires minor fixes to allow bundeling libpq
PYTHON_WASIX_BINARIES_WHEELS+=psycopg_binary-3.2.9-cp313-cp313-wasix_wasm32
# Included: Build in build-script requires minor fixes to allow bundeling libpq
PYTHON_WASIX_BINARIES_WHEELS+=psycopg_pool-3.2.6-py3-none-any
# Not included: Source build in build-scripts
# PYTHON_WASIX_BINARIES_WHEELS+=pyarrow-19.0.1-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=pycryptodome-3.23.0-cp37-abi3-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=pycryptodomex-3.23.0-cp37-abi3-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=pydantic_core-2.33.2-cp313-cp313-wasix_wasm32
# Included: Not moved to build-scripts yet
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=pynacl-1.5.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=pytz-cp313-cp313-wasix_wasm32
# Included: Not moved to build-scripts yet
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=pyyaml-6.0.2-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=regex-2025.5.18-cp313-cp313-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=rpds_py-0.26.0-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=shapely-2.1.1-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=six-cp313-cp313-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=tiktoken-0.9.0-cp313-cp313-wasix_wasm32
# Included: Rust
PYTHON_WASIX_BINARIES_WHEELS+=tokenizers-0.21.3-cp313-cp313-wasix_wasm32
# Included: Not moved to build-scripts yet. Does not seem native.
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=tornado-6.5.2-cp39-abi3-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=tzdata-cp313-cp313-wasix_wasm32
# Not included: Source build in build-scripts
#PYTHON_WASIX_BINARIES_WHEELS+=uvloop-0.21.0-cp313-cp313-wasix_wasm32
# Included: Not moved to build-scripts yet. Does not seem native.
# TODO: Move to build-scripts
PYTHON_WASIX_BINARIES_WHEELS+=watchdog-6.0.0-py3-none-any
# Libs build a .tar.xz file with a sysroot
LIBS=
LIBS+=zbar
LIBS+=libffi
LIBS+=pandoc
LIBS+=postgresql
LIBS+=brotli
LIBS+=zlib
LIBS+=libjpeg-turbo
LIBS+=xz
LIBS+=libtiff
LIBS+=libwebp
LIBS+=giflib
LIBS+=libpng
LIBS+=SDL3
LIBS+=openjpeg
LIBS+=libuv
LIBS+=mariadb-connector-c
LIBS+=openssl
LIBS+=util-linux
# LIBS+=dropbear # Requires fork/exec to compile
LIBS+=tinyxml2
LIBS+=geos
LIBS+=libxslt
LIBS+=libxml2
LIBS+=google-crc32c
LIBS+=arrow19-0-1
LIBS+=arrow
LIBS+=rapidjson
LIBS+=icu
LIBS+=ncurses
LIBS+=readline
LIBS+=curl
LIBS+=sqlite
LIBS+=wasix-libc # Replaced by the sysroot shipped with wasixcc
LIBS+=libcxx # Replaced by the sysroot shipped with wasixcc
LIBS+=compiler-rt # Replaced by the sysroot shipped with wasixcc
LIBS+=cpython
LIBS+=libb2
LIBS+=zstd
LIBS+=jq
LIBS+=onigurama
LIBS+=bzip2
LIBS+=xxhash
LIBS+=lz4
LIBS+=snappy
LIBS+=lzo
LIBS+=ca-certificates
LIBS+=gmp
LIBS+=mpfr
LIBS+=zz
# Packages that are broken can be marked as DONT_BUILD
# Packages that work but should not be included in the default install can be marked as DONT_INSTALL
DONT_BUILD=
# Dont build psycopg-binary, because it does not work
DONT_BUILD+=psycopg-binary
# Build is currently broken and I don't know why. It worked before. Continue here if you need 2.0.2
DONT_BUILD+=numpy2-0-2
DONT_INSTALL=$(DONT_BUILD)
# Dont install pypandoc because it uses the same name as pypandoc_binary
DONT_INSTALL+=pypandoc
# Dont install numpy1, because we already have numpy 2
DONT_INSTALL+=numpy1
DONT_INSTALL+=numpy2-0-2
DONT_INSTALL+=numpy2-3-2
# Dont install pandas 2.2.3, because we have a newer version
DONT_INSTALL+=pandas2-2-3
# Dont install cryptography 43.0.3, because we have a newer version
DONT_INSTALL+=cryptography43-0-3
# Dont install old pyarrow, because we already have the new one
DONT_INSTALL+=pyarrow19-0-1
# Dont install psycopg from build-scripts as I am to lazy to check if they work
DONT_INSTALL+=psycopg-pool
DONT_INSTALL+=psycopg
# Helper function to get the project name from a path
project_name = $(basename $(basename $(notdir $(1))))
patches_for = $(shell find ${PATCH_DIR} -name '$(call project_name,$(1))-00*.patch' | sort)
# Helper functions to generate the paths to targets
# Targets should only ever be addressed by these functions
in_pkgs_with_suffix = $(addprefix pkgs/,$(addsuffix $(1),$(call project_name,$(2))))
source = $(call in_pkgs_with_suffix,.source,$(1))
prepared = $(call in_pkgs_with_suffix,.prepared,$(1))
build = $(call in_pkgs_with_suffix,.build,$(1))
targz = $(call in_pkgs_with_suffix,.tar.gz,$(1))
tarxz = $(call in_pkgs_with_suffix,.tar.xz,$(1))
sdist = $(call in_pkgs_with_suffix,.sdist,$(1))
whl = $(call in_pkgs_with_suffix,.whl,$(1))
wheel = $(call in_pkgs_with_suffix,.wheel,$(1))
lib = $(call in_pkgs_with_suffix,.lib,$(1))
tarxzunpacked = $(call in_pkgs_with_suffix,.tar.xz.unpacked,$(1))
sysroot = $(call in_pkgs_with_suffix,.sysroot,$(1))
WHEEL_SUBMODULES=$(call source,$(WHEELS))
LIB_SUBMODULES=$(call source,$(LIBS))
SUBMODULES=$(WHEEL_SUBMODULES) $(LIB_SUBMODULES)
PREPARED_SUBMODULES=$(call prepared,$(SUBMODULES))
BUILT_WHEELS=$(call whl,$(filter-out $(DONT_BUILD),$(WHEELS)))
UNPACKED_WHEELS=$(call wheel,$(WHEELS))
BUILT_SDISTS=$(call targz,$(WHEELS))
UNPACKED_SDISTS=$(call sdist,$(WHEELS))
PREPACKED_LIBS=$(call lib,$(LIBS))
UNPACKED_LIBS=$(call tarxzunpacked,$(LIBS))
BUILT_LIBS=$(call tarxz,$(filter-out $(DONT_BUILD),$(LIBS)))
# Names of the wheels and libs that we want to install
BUILT_WHEELS_TO_INSTALL_NAMES=$(filter-out $(DONT_INSTALL),$(WHEELS))
PWB_WHEELS_TO_INSTALL_NAMES=$(filter-out $(DONT_INSTALL),$(PYTHON_WASIX_BINARIES_WHEELS))
BUILT_LIBS_TO_INSTALL_NAMES=$(filter-out $(DONT_INSTALL),$(LIBS))
# Paths to the .whl and .tar.xz files that we want to install
BUILT_WHEELS_TO_INSTALL=$(call whl,$(BUILT_WHEELS_TO_INSTALL_NAMES))
PWB_WHEELS_TO_INSTALL=$(addprefix ${PYTHON_WASIX_BINARIES}/wheels/,$(addsuffix .whl,$(PWB_WHEELS_TO_INSTALL_NAMES)))
BUILT_LIBS_TO_INSTALL=$(call tarxz,$(BUILT_LIBS_TO_INSTALL_NAMES))
# Marker files to indicate that the wheels and libs have been installed
ALL_INSTALLED_WHEELS=$(addprefix ${WHEELS_DESTDIR}/.,$(addsuffix .installed,$(BUILT_WHEELS_TO_INSTALL_NAMES)))
ALL_INSTALLED_WHEELS+=$(addprefix ${WHEELS_DESTDIR}/.pwb-,$(addsuffix .installed,$(PWB_WHEELS_TO_INSTALL_NAMES)))
ALL_INSTALLED_LIBS=$(addprefix ${LIBS_DESTDIR}/.,$(addsuffix .installed,$(BUILT_LIBS_TO_INSTALL_NAMES)))
# mkdir but resets the timestamp if it didnt exist before
define reset_install_dir
bash -c 'rm -rf $$1 ; mkdir $$1 && touch -t 201001010001.00 $$1 || true' .
endef
define reset_submodule =
rm -rf $(abspath $(dir $@))
$(GIT) restore $(dir $@)
$(GIT) submodule update --init --recursive $(dir $@)
cd $(dir $@) && $(GIT) clean -dxf >/dev/null 2>&1 || true
cd $(dir $@) && make clean >/dev/null 2>&1 || true
cd $(dir $@) && rm -f clean 2>&1 || true
cd $(dir $@) && $(GIT) am --abort >/dev/null 2>&1 || true
endef
define prepare_submodule =
test -n "$@"
cd $@ && $(GIT) worktree remove . >/dev/null 2>&1 || true
rm -rf ${PWD}/$@
cd $(call source,$@) && $(GIT) worktree prune >/dev/null 2>&1 || true
cd $(call source,$@) && $(GIT) worktree add --checkout --detach ${PWD}/$@
# Quite a long command to clone submodules from the source directory instead of the remote
cd $@ && $(GIT) -c protocol.file.allow=always $$(cd ${PWD}/$(call source,$@) && $(GIT) submodule foreach --recursive bash -c 'echo -c url.file://$$(pwd).insteadOf=$$($(GIT) remote get-url origin)' | grep -v Entering | xargs echo) submodule update --init --recursive --progress
cd $@ && $(GIT) am --abort >/dev/null 2>&1 || true
cd $@ && echo | $(GIT) am $(call patches_for,$(call project_name,$@))
endef
# Customizable build script
# PYPROJECT_PATH is the path to the pyproject.toml relative to the submodule. Defaults to the submodule which is usually correct
# BUILD_ENV_VARS is a space separated list of environment variables to pass to the build script. Defaults to empty
# BUILD_EXTRA_FLAGS is a space separated list of extra flags to pass to the build script. Defaults to empty
# PREPARE is a command to run before building the wheel. Defaults to empty. Runs inside the submodule directory
define build_wheel =
mkdir -p pkgs
if test -n "${PREPARE}" ; then source ./cross-venv/bin/activate && cd $(call sdist,$@) && _= ${PREPARE} ; fi
source ./cross-venv/bin/activate && cd $(call sdist,$@) && $(call set_sysroot,python-wheels) ${BUILD_ENV_VARS} python3 -m build --wheel ${BUILD_EXTRA_FLAGS}
mkdir -p artifacts
cp $(call sdist,$@)/dist/*[2y].whl artifacts
# [2y] is a hack to match anything ending in wasm32 or any
ln -sf ../artifacts/$$(basename $(call sdist,$@)/dist/*[2y].whl) $@
endef
define build_sdist =
mkdir -p pkgs
if test -n "${PREPARE}" ; then source ./cross-venv/bin/activate && cd $(call build,$@) && _= ${PREPARE} ; fi
source ./cross-venv/bin/activate && cd $(call build,$@)/${PYPROJECT_PATH} && $(call set_sysroot,python-wheels) ${BUILD_ENV_VARS} python3 -m build --sdist ${BUILD_EXTRA_FLAGS}
mkdir -p artifacts
cp $(call build,$@)/${PYPROJECT_PATH}/dist/*[0-9].tar.gz artifacts
ln -sf ../artifacts/$$(basename $(call build,$@)/${PYPROJECT_PATH}/dist/*[0-9].tar.gz) $@
endef
# Bundle the first dependency to a tar.xz file in artifacts and link it to the target
define package_lib =
mkdir -p artifacts
cd $< && tar cfJ ${PWD}/artifacts/$(notdir $@) *
ln -sf $(shell realpath -s --relative-to="${PWD}/$(dir $@)" "${PWD}/artifacts/$(notdir $@)") $@
endef
define assemble_sysroot =
$(reset_install_dir) $@
$(foreach dep,$^,if test "$(dep)" != "$(call tarxz,$(dep))" && test "$(dep)" != "$(call sysroot,$(dep))" ; then echo "The dependencies of a sysroot must be .tar.xz artifacts or other sysroots (got $(dep))." 1>&2 ; exit 1 ; fi ;)
$(foreach dep,$(filter %.sysroot,$^),cp -rfT ${PWD}/$(call sysroot,$(dep)) ${PWD}/$@ || exit 1;)
$(foreach dep,$(filter %.tar.xz,$^),$(call install_tarxz,${PWD}/$@,$(call project_name,$(dep))) || exit 1;)
touch $@
endef
# Build a webc from a directory containing a wasmer.toml file
define build_webc =
mkdir -p artifacts
test -f $<$|/wasmer.toml
rm -f artifacts/$(notdir $(basename $@))2.webc
${WASMER} package build $<$| --out artifacts/$(notdir $(basename $@))2.webc
mv artifacts/$(notdir $(basename $@))2.webc artifacts/$(notdir $(basename $@)).webc
ln -sf $(shell realpath -s --relative-to="${PWD}/$(dir $@)" "${PWD}/artifacts/$(notdir $@)") $@
touch $@
endef
# Ensure that we are in a sysroot
define ensure_sysroot =
if ! test -d $@/usr/local/lib/wasm32-wasi ; then echo "Cannot remove shared libs from $@/usr/local/lib/wasm32-wasi, directory does not exist." 1>&2 ; exit 1 ; fi
endef
# Check if any of the supplied patterns match the first argument
define bash_pattern_match =
[[ $(foreach pattern,$(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9),"$(1)" == ${pattern} || ) 1 == 2 ]]
endef
# Remove all shared libs from a sysroot
define remove_shared_libs =
$(call ensure_sysroot)
for file in $@/usr/local/lib/wasm32-wasi/*.so* ; do if test -f $$file ; then rm -f $$file ; fi ; done
endef
# Remove all shared libs from a sysroot except the ones matching one of the supplied patterns
define remove_shared_libs_except =
$(call ensure_sysroot)
for file in $@/usr/local/lib/wasm32-wasi/*.so* ; do if ! $(call bash_pattern_match,$$(basename "$$file"),$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8)) ; then rm -f $$file ; fi ; done
endef
# Remove all shared libs from a sysroot matching one of the supplied patterns
define remove_shared_libs_only =
$(call ensure_sysroot)
for file in $@/usr/local/lib/wasm32-wasi/*.so* ; do if $(call bash_pattern_match,$$(basename "$$file"),$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8)) ; then rm -f $$file ; fi ; done
endef
# Remove all files from a sysroot that are not libs or headers
define clean_sysroot =
$(call ensure_sysroot)
cd $@ ; rm -rf ./share ./usr/share ./usr/local/share
cd $@ ; rm -rf ./bin ./usr/bin ./usr/local/bin
cd $@ ; rm -rf ./sbin ./usr/sbin ./usr/local/sbin
cd $@ ; rm -rf ./etc ./usr/etc ./usr/local/etc
cd $@ ; rm -rf ./man ./usr/man ./usr/local/man
endef
# Set some environment variables based on the build sysroot
define set_sysroot =
WASIXCC_SYSROOT=${PWD}/$(if $(1),$(call sysroot,$(1)),$(call sysroot,default)) \
PKG_CONFIG_SYSROOT_DIR=${PWD}/$(if $(1),$(call sysroot,$(1)),$(call sysroot,default)) \
PKG_CONFIG_LIBDIR=${PWD}/$(if $(1),$(call sysroot,$(1)),$(call sysroot,default))/usr/local/lib/wasm32-wasi/pkgconfig \
CMAKE_PREFIX_PATH=${PWD}/$(if $(1),$(call sysroot,$(1)),$(call sysroot,default))/usr/local/lib/wasm32-wasi/cmake \
endef
# Command to run something in an environment with a haskell compiler targeting wasi
# Uses an older hash, because the latest version requires tail call support
RUN_WITH_HASKELL=nix shell 'gitlab:haskell-wasm/ghc-wasm-meta/6a8b8457df83025bed2a8759f5502725a827104b?host=gitlab.haskell.org' --command
# TODO: Find a better solution for adding -o with all the artifacts
all-but-dont-require-rebuild:
make all $$(for pkg in pkgs/*.whl pkgs/*.tar.gz pkgs/*.tar.xz ; do printf -- '-o %s ' "$$pkg"; done)
python-with-packages-but-dont-require-rebuild:
make python-with-packages $$(for pkg in pkgs/*.whl pkgs/*.tar.gz pkgs/*.tar.xz ; do printf -- '-o %s ' "$$pkg"; done)
all: $(BUILT_LIBS) $(BUILT_WHEELS) $(PWB_WHEELS_TO_INSTALL)
wheels: $(BUILT_WHEELS)
external-wheels: $(PWB_WHEELS_TO_INSTALL)
libs: $(BUILT_LIBS)
install: install-wheels install-libs
install-wheels: $(ALL_INSTALLED_WHEELS)
install-libs: $(ALL_INSTALLED_LIBS)
test: python-with-packages
test -n "$$(command -v docker)" || (echo "You must have docker installed to run the tests" && exit 1)
docker kill wasix-tests-mysql || true
docker kill wasix-tests-postgres || true
docker kill wasix-tests-clickhouse || true
docker run --rm -it -d --name wasix-tests-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mysql:latest
docker run --rm -it -d --name wasix-tests-postgres -p 5432:5432 -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mypassword -e POSTGRES_DB=mydatabase postgres
docker run --rm -it -d --name wasix-tests-clickhouse -e CLICKHOUSE_DB=mydatabase -e CLICKHOUSE_USER=myuser -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=mypassword -p 8123:8123 -p 9003:9000/tcp clickhouse/clickhouse-server
bash run-tests.sh
docker kill wasix-tests-mysql || true
docker kill wasix-tests-postgres || true
docker kill wasix-tests-clickhouse || true
# Make sure that python-wasix-binaries is initialized
python-wasix-binaries/.git:
git submodule update --init --recursive python-wasix-binaries
##### Extracted webcs for testing #####
PYTHON_WEBC=python/python
PYTHON_BASE_WEBC=python/python-base
PYTHON_WITH_PACKAGES_WEBC=python/python-with-packages
python-base: pkgs/python-base.webc
${WASMER} package unpack $<$| --out-dir $@
cp $@/modules/python $@/root/usr/local/bin/python3.wasm
touch $@
python: pkgs/python.webc
${WASMER} package unpack $<$| --out-dir $@
cp $@/modules/python $@/root/usr/local/bin/python3.wasm
touch $@
python-with-packages: pkgs/python-with-packages.webc
${WASMER} package unpack $<$| --out-dir $@
cp $@/modules/python $@/root/usr/local/bin/python3.wasm
touch $@
##### Preparing a wasm crossenv #####
build-index-venv:
python3 -m venv ./build-index-venv
source ./build-index-venv/bin/activate && pip install dumb_pypi
native-venv:
python3 -m venv ./native-venv
source ./native-venv/bin/activate && pip install crossenv
$(call sysroot,python-wheels): $(call sysroot,cpython) $(call tarxz,cpython)
$(assemble_sysroot)
cross-venv: native-venv | $(call sysroot,python-wheels)
rm -rf ./cross-venv
source ./native-venv/bin/activate && python3 -m crossenv $(call sysroot,python-wheels)/usr/local/bin/python3.wasm ./cross-venv --cc wasixcc --cxx wasixcc++
source ./cross-venv/bin/activate && PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple build-pip install cffi
# Run with the native tools because we need to build maturin from source for the build system
# Setuptools 81.0.0 is required as 82.0.0 removed pkg_resources which is required for building uvloop. We should be able to upgrade to 82.0.0 once uvloop is updated to not require pkg_resources anymore.
source ./cross-venv/bin/activate && ${ENV_VARS_FOR_NATIVE_TOOLS} PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple pip install build six cython setuptools==81.0.0 wheel git+https://github.com/wasix-org/maturin.git@wasix-1.9.0
cp ./cross-venv/cross/bin/maturin.wasm ./cross-venv/cross/bin/maturin
##### Preparing submodules #####
# A target for making sure a submodule is clean
# To override the reset behaviour, add a target for your submodule
$(PREPARED_SUBMODULES): %:
$(foreach name,$(LIBS) $(WHEELS),$(eval pkgs/$(name).prepared: $(call patches_for,$(name))))
$(PREPARED_SUBMODULES): $(call prepared,%): $(call source,%)
$(call prepared,%):
$(prepare_submodule)
$(call source,%): $(call source,%)/.git
touch $@
$(call source,%)/.git:
$(reset_submodule)
$(call build,%): $(call prepared,%)
mkdir -p pkgs
rm -rf $@
cp -rf $< $@
$(call prepared,pycryptodomex):
$(prepare_submodule)
# If that file exists, pycryptodome will be built with a separate namespace
touch $@/.separate_namespace
$(call prepared,pypandoc_binary):
$(prepare_submodule)
# pyproject.toml only works for the non-binary wheel, because they are still moving to pyproject.toml
mv $@/setup_binary.py $@/setup.py
rm $@/pyproject.toml
# The pandoc binary also needs to be copied, but we do that in the build step
$(call prepared,protobuf):
$(prepare_submodule)
# The bazel toolchain files need to be in the repository
cp -r $(BAZEL_TOOLCHAIN) $@/wasix-toolchain
$(call prepared,grpc):
$(prepare_submodule)
cd $@/third_party/abseil-cpp && $(GIT) am $(call patches_for,abseil-cpp)
$(call prepared,rapidjson):
$(prepare_submodule)
# Cherrypick the commits from https://github.com/Tencent/rapidjson/pull/719 onto the latest release
cd $@ && $(GIT) cherry-pick 3b2441b87f99ab65f37b141a7b548ebadb607b96
cd $@ && $(GIT) cherry-pick 862c39be371278a45a88d4d1d75164be57bb7e2d
$(call prepared,pyarrow):
$(prepare_submodule)
# Tag so we get a clean name after applying the patch
cd $@ && $(GIT) tag -fam "" apache-arrow-21.0.0
$(call prepared,pyarrow19-0-1):
$(prepare_submodule)
# Tag so we get a clean name after applying the patch
cd $@ && $(GIT) tag -fam "" apache-arrow-19.0.1
$(call prepared,matplotlib):
$(prepare_submodule)
# Tag so we get a clean name after applying the patches
cd $@ && $(GIT) tag -fam "" v3.10.6
$(call prepared,shapely):
$(prepare_submodule)
# Tag so we get a clean name after applying the patches
# cd $@ && $(GIT) tag -fam "" $$(${GIT} -C ${PWD}/$(call source,$@) describe HEAD)
cd $@ && $(GIT) tag -fam "" 2.1.1
$(call prepared,greenlet):
$(prepare_submodule)
# Fix the version number so that it matches the wheel we build
cd $@ && sed -i 's/3.2.5.dev0/3.2.4/' src/greenlet/__init__.py
$(call prepared,aiohttp):
$(prepare_submodule)
# Apply some patch from arshia.
# TODO: Review if this is still needed
cd $@/vendor/llhttp && git fetch origin c11271f223118301a9e3aee314f968fdedb7fbcc
cd $@/vendor/llhttp && git cherry-pick c11271f223118301a9e3aee314f968fdedb7fbcc
##### Building webcs #####
$(call lib,python-base-webc): $(call tarxz,cpython) $(call sysroot,cpython) $(call tarxz,ca-certificates) resources/python-webc/wasmer.toml $(call tarxz,ncurses)
mkdir -p $@/root
$(call install_tarxz,${PWD}/$@/root,cpython)
$(call install_tarxz,${PWD}/$@/root,ca-certificates)
rm -rf ${PWD}/$@/root/.install*
# Install to /lib because wasmer currently does not look in wasm32-wasi for shared libs
mkdir -p $@/root/lib
cp -L $(call sysroot,cpython)/usr/local/lib/wasm32-wasi/libcrypto.so $@/root/lib
cp -L $(call sysroot,cpython)/usr/local/lib/wasm32-wasi/libssl.so $@/root/lib
cp -L $(call sysroot,cpython)/usr/local/lib/wasm32-wasi/libsqlite3.so $@/root/lib
# Install openssl legacy module
mkdir -p $@/root/usr/local/lib/wasm32-wasi/ossl-modules
cp -L $(call sysroot,cpython)/usr/local/lib/wasm32-wasi/ossl-modules/legacy.so $@/root/usr/local/lib/wasm32-wasi/ossl-modules
# Install terminfo database from ncurses
mkdir -p $@/root/usr/local/share/terminfo
TEMP_DIR=$$(mktemp -d) ; \
$(call install_tarxz,$$TEMP_DIR,ncurses) \
cp -rT $$TEMP_DIR/usr/local/share/terminfo $@/root/usr/local/share/terminfo
cp resources/python-webc/wasmer.toml $@/wasmer.toml
tomlq -i '.package.name = "$(PYTHON_BASE_WEBC)"' $@/wasmer.toml --output-format toml
touch $@
$(call lib,python-webc): $(call lib,python-base-webc)
rm -rf $@
cp -r $(call lib,python-base-webc) $@
# Remove selftests
rm -rf $@/root/usr/local/lib/python3.13/test
# Remove static libpython in config
rm -rf $@/root/usr/local/lib/python3.13/config-3.13-wasm32-wasi/libpython3.13.a
# Remove pycache
find $@/root -name '__pycache__' | xargs rm -r
# Remove static libpython
rm -rf $@/root/usr/local/lib/libpython3.13.a
# Remove python3.13.wasm
rm $@/root/usr/local/bin/python3.wasm
mv $@/root/usr/local/bin/python3.13.wasm $@/root/usr/local/bin/python3.wasm
# Remove all terminfo files except dumb
mv $@/root/usr/local/share/terminfo/d/dumb $@/root/usr/local/share
rm -rf $@/root/usr/local/share/terminfo
mkdir -p $@/root/usr/local/share/terminfo/d
mv $@/root/usr/local/share/dumb $@/root/usr/local/share/terminfo/d/dumb
# Remove other files that are not strictly neccessary
find $@/root -name '*.exe' | xargs rm -r # 500K of random exe files
rm -rf $@/root/usr/local/share/man # 20k of manpages
rm -rf $@/root/usr/local/include # 2.4MB of headers
rm -rf $@/root/usr/local/lib/python3.13/site-packages/pip* # 6.8MB of pip
rm -rf $@/root/usr/local/lib/pkgconfig # 12KB of pkgconfig files
rm -rf $@/root/usr/local/lib/python3.13/ensurepip # 1.7MB of bundled pip
# Strip debug symbols and optimize binaries again
wasm-opt --emit-exnref -O3 --strip-debug $@/root/usr/local/bin/python3.wasm -o $@/root/usr/local/bin/python3.wasm
wasm-opt --emit-exnref -O3 --strip-debug $@/root/lib/libsqlite3.so -o $@/root/lib/libsqlite3.so
wasm-opt --emit-exnref -O3 --strip-debug $@/root/lib/libssl.so -o $@/root/lib/libssl.so
wasm-opt --emit-exnref -O3 --strip-debug $@/root/lib/libcrypto.so -o $@/root/lib/libcrypto.so
wasm-opt --emit-exnref -O3 --strip-debug $@/root/usr/local/lib/wasm32-wasi/ossl-modules/legacy.so -o $@/root/usr/local/lib/wasm32-wasi/ossl-modules/legacy.so
# Update the name in the wasmer.toml
tomlq -i '.package.name = "$(PYTHON_WEBC)"' $@/wasmer.toml --output-format toml
touch $@
$(call lib,python-with-packages-webc): $(call lib,python-base-webc) $(BUILT_WHEELS_TO_INSTALL) $(PWB_WHEELS_TO_INSTALL)
rm -rf $@
cp -r $(call lib,python-base-webc) $@
# TODO: Install wheels
WHEELS_DESTDIR=${PWD}/$(call lib,python-with-packages-webc)/root/usr/local/lib/python3.13 make install-wheels $$(for pkg in pkgs/*.whl ; do printf -- '-o %s ' "$$pkg"; done)
# Update the name in the wasmer.toml
tomlq -i '.package.name = "$(PYTHON_WITH_PACKAGES_WEBC)"' $@/wasmer.toml --output-format toml
touch $@
pkgs/python.webc: $(call lib,python-webc)
$(build_webc)
pkgs/python-base.webc: | $(call lib,python-base-webc)
$(build_webc)
pkgs/python-with-packages.webc: $(call lib,python-with-packages-webc)
$(build_webc)
##### Building wheels #####
# A target to build a wheel from a python submodule
# To override the build behaviour, add a target for your submodule
$(BUILT_WHEELS): $(call whl,%): $(call sdist,%) | cross-venv
$(call whl,%): WASIXCC_SYSROOT = ${PWD}/$(call sysroot,default)
$(call whl,%): $(call sdist,%) $(call sysroot,default)
$(build_wheel)
$(BUILT_SDISTS): $(call targz,%): $(call build,%) | cross-venv
$(call targz,%): WASIXCC_SYSROOT = ${PWD}/$(call sysroot,default)
$(call targz,%): $(call build,%) $(call sysroot,default)
$(build_sdist)
$(UNPACKED_SDISTS): $(call sdist,%): $(call targz,%) | cross-venv
$(call sdist,%): $(call targz,%)
rm -rf $@
mkdir -p $@
tar -xzf $^ -C $@ --strip-components=1
$(UNPACKED_WHEELS): $(call wheel,%): | cross-venv
$(call wheel,%): $(call whl,%)
rm -rf $@
mkdir -p $@
unzip -oq $< -d $@
# Depends on zbar headers being installed
# setup.py is not in the root directory
$(call targz,pytz): PYPROJECT_PATH = build/dist
# Build the tzdb locally
$(call targz,pytz): PREPARE = CCC_OVERRIDE_OPTIONS='^--target=x86_64-unknown-linux' CC=clang CXX=clang++ make build
$(call targz,psycopg): PYPROJECT_PATH = psycopg
$(call targz,psycopg-pool): PYPROJECT_PATH = psycopg_pool
$(call targz,psycopg-binary): PYPROJECT_PATH = psycopg_binary
$(call targz,psycopg-binary): PREPARE = rm -rf psycopg_binary && python3 tools/build/copy_to_binary.py
# Inject a mock pg_config to the PATH, so the build process can find it
$(call whl,psycopg-binary): BUILD_ENV_VARS = PATH="${PWD}/resources:$$PATH" WASIXCC_FORCE_STATIC_DEPENDENCIES=true
# Pretend we are a normal posix-like target, so we automatically include <endian.h>
$(call whl,psycopg-binary): export CCC_OVERRIDE_OPTIONS = ^-D__linux__=1
$(call sysroot,pillow): $(call sysroot,python-wheels) $(call tarxz,libjpeg-turbo) $(call tarxz,libpng) $(call tarxz,libtiff) $(call tarxz,libwebp) $(call tarxz,giflib) $(call tarxz,openjpeg)
$(assemble_sysroot)
$(call remove_shared_libs)
$(call whl,pillow): $(call sysroot,pillow)
$(call whl,pillow): BUILD_ENV_VARS = $(call set_sysroot,pillow) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
$(call whl,pillow): BUILD_EXTRA_FLAGS = -Cplatform-guessing=disable
$(call sysroot,lxml): $(call sysroot,python-wheels) $(call tarxz,libxslt) $(call tarxz,libxml2)
$(assemble_sysroot)
$(call remove_shared_libs)
# We need to install, because we can only specify one sysroot in pkgconfig
$(call targz,lxml): $(call sysroot,lxml)
$(call targz,lxml): BUILD_ENV_VARS = $(call set_sysroot,lxml) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
$(call whl,lxml): BUILD_ENV_VARS = $(call set_sysroot,lxml) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
$(call targz,dateutil): PREPARE = python3 updatezinfo.py
# Needs to run a cython command before building the wheel
$(call targz,msgpack-python): PREPARE = make cython
# Depends on a meson crossfile
$(call targz,numpy): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call targz,numpy): ${MESON_CROSSFILE}
$(call whl,numpy): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call whl,numpy): ${MESON_CROSSFILE}
# Depends on a meson crossfile
$(call targz,numpy1): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call targz,numpy1): ${MESON_CROSSFILE}
$(call whl,numpy1): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call whl,numpy1): ${MESON_CROSSFILE}
$(call targz,numpy2-0-2): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}" -Cbuild-dir=build
$(call targz,numpy2-0-2): ${MESON_CROSSFILE}
$(call whl,numpy2-0-2): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}" -Cbuild-dir=build
$(call whl,numpy2-0-2): ${MESON_CROSSFILE}
$(call targz,numpy2-3-2): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}" -Cbuild-dir=build
$(call targz,numpy2-3-2): ${MESON_CROSSFILE}
$(call whl,numpy2-3-2): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}" -Cbuild-dir=build
$(call whl,numpy2-3-2): ${MESON_CROSSFILE}
$(call sysroot,shapely): $(call sysroot,python-wheels) $(call tarxz,geos)
$(call whl,shapely): $(call sysroot,shapely)
# TODO: Static build don't work yet, because we would have to specify recursive dependencies manually
# $(call whl,shapely): BUILD_ENV_VARS += WASIXCC_FORCE_STATIC_DEPENDENCIES=true
# Set geos paths
$(call whl,shapely): BUILD_ENV_VARS += $(call set_sysroot,shapely)
$(call whl,shapely): BUILD_ENV_VARS += GEOS_INCLUDE_PATH="${PWD}/$(call sysroot,shapely)/usr/local/include"
$(call whl,shapely): BUILD_ENV_VARS += GEOS_LIBRARY_PATH="${PWD}/$(call sysroot,shapely)/usr/local/lib/wasm32-wasi"
# Use numpy dev build from our registry. Our patches have been merged upstream, so for the next numpy release we can remove this.
$(call whl,shapely): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,shapely): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,shapely): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,shapely): BUILD_EXTRA_FLAGS = --skip-dependency-check
# Needs to have the pypandoc executable in the repo
$(call whl,pypandoc_binary): $(call sdist,pypandoc_binary)/pypandoc/files/pandoc
$(call sdist,pypandoc_binary)/pypandoc/files/pandoc: $(call sdist,pypandoc_binary) $(call tarxz,pandoc)
mkdir -p $(call sdist,pypandoc_binary)/pypandoc/files
tar xfJ $(call tarxz,pandoc) -C $(call sdist,pypandoc_binary)/pypandoc/files --strip-components=1 bin/pandoc
touch $@
$(call sysroot,uvloop): $(call sysroot,python-wheels) $(call tarxz,libuv)
$(assemble_sysroot)
$(call remove_shared_libs)
$(call whl,uvloop): $(call sysroot,uvloop)
$(call whl,uvloop): BUILD_ENV_VARS = $(call set_sysroot,uvloop) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
$(call whl,uvloop): BUILD_EXTRA_FLAGS = '-C--build-option=build_ext --use-system-libuv'
$(call targz,aiohttp): PREPARE = make cythonize ; yes | make generate-llhttp
$(call sysroot,mysqlclient): $(call sysroot,python-wheels) $(call tarxz,mariadb-connector-c)
$(assemble_sysroot)
# Link files to make forced static linking work
ln -s libmariadbclient.a $@/usr/local/lib/wasm32-wasi/libmariadb.a
ln -s libmysqlclient.a $@/usr/local/lib/wasm32-wasi/libmysql.a
$(call targz,mysqlclient): $(call sysroot,mysqlclient)
$(call targz,mysqlclient): BUILD_ENV_VARS = $(call set_sysroot,mysqlclient) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
$(call whl,mysqlclient): $(call sysroot,mysqlclient)
$(call whl,mysqlclient): BUILD_ENV_VARS = $(call set_sysroot,mysqlclient) WASIXCC_FORCE_STATIC_DEPENDENCIES=true
# Use numpy dev build from our registry. Our patches have been merged upstream, so for the next numpy release we can remove this.
$(call targz,pandas): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,pandas): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
# $(call targz,pandas): BUILD_ENV_VARS += PIP_NO_CACHE_DIR=1
$(call targz,pandas): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,pandas): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call targz,pandas): ${MESON_CROSSFILE}
$(call whl,pandas): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,pandas): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,pandas): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,pandas): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call whl,pandas): ${MESON_CROSSFILE}
# Use numpy dev build from our registry. Our patches have been merged upstream, so for the next numpy release we can remove this.
$(call targz,pandas2-2-3): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,pandas2-2-3): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
# $(call targz,pandas2-2-3): BUILD_ENV_VARS += PIP_NO_CACHE_DIR=1
$(call targz,pandas2-2-3): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,pandas2-2-3): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call targz,pandas2-2-3): ${MESON_CROSSFILE}
$(call whl,pandas2-2-3): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,pandas2-2-3): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,pandas2-2-3): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,pandas2-2-3): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call whl,pandas2-2-3): ${MESON_CROSSFILE}
$(call targz,protobuf):
mkdir -p pkgs
cd $(call build,protobuf)/python && bazel clean --expunge
cd $(call build,protobuf)/python && ${ENV_VARS_FOR_NATIVE_TOOLS} bazel build //python/dist:source_wheel --crosstool_top=//wasix-toolchain:wasix_toolchain --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=wasm32-wasi
mkdir -p artifacts
install -m666 $(call build,protobuf)/bazel-bin/python/dist/protobuf.tar.gz artifacts
ln -rsf ${PWD}/artifacts/protobuf.tar.gz $@
$(call sysroot,pyarrow19-0-1): $(call sysroot,python-wheels) $(call tarxz,arrow19-0-1)
$(assemble_sysroot)
$(call remove_shared_libs)
$(call targz,pyarrow19-0-1): $(call sysroot,pyarrow19-0-1)
$(call targz,pyarrow19-0-1): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,pyarrow19-0-1): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call targz,pyarrow19-0-1): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,pyarrow19-0-1): PYPROJECT_PATH = python
$(call whl,pyarrow19-0-1): $(call sysroot,pyarrow19-0-1)
$(call whl,pyarrow19-0-1): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,pyarrow19-0-1): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,pyarrow19-0-1): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,pyarrow19-0-1): BUILD_ENV_VARS += $(call set_sysroot,pyarrow19-0-1)
$(call sysroot,pyarrow): $(call sysroot,python-wheels) $(call tarxz,arrow)
$(assemble_sysroot)
$(call remove_shared_libs)
$(call targz,pyarrow): $(call sysroot,pyarrow)
$(call targz,pyarrow): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,pyarrow): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call targz,pyarrow): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,pyarrow): PYPROJECT_PATH = python
$(call whl,pyarrow): $(call sysroot,pyarrow)
$(call whl,pyarrow): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,pyarrow): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,pyarrow): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,pyarrow): BUILD_ENV_VARS += $(call set_sysroot,pyarrow)
$(call targz,matplotlib): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,matplotlib): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call targz,matplotlib): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,matplotlib): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call targz,matplotlib): ${MESON_CROSSFILE}
$(call whl,matplotlib): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,matplotlib): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,matplotlib): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,matplotlib): BUILD_EXTRA_FLAGS = -Csetup-args="--cross-file=${MESON_CROSSFILE}"
$(call whl,matplotlib): ${MESON_CROSSFILE}
$(call targz,gevent): BUILD_ENV_VARS += PIP_TRUSTED_HOST=0.0.0.0 PIP_EXTRA_INDEX_URL=http://0.0.0.0:6931/simple
$(call targz,gevent): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo greenlet==3.3.0 > $$F ; echo $$F)
$(call targz,gevent): BUILD_ENV_VARS += GEVENTSETUP_USE_LIBUV=0
$(call targz,gevent): $(call build,gevent) $(call sysroot,default) $(call whl,greenlet) build-index-venv
source ./build-index-venv/bin/activate && python3 generate-index.py
# This is dumb, because the server is never stopped...
python3 -m http.server 6931 --directory $(PWD)/dist || true &
$(build_sdist)
$(call whl,gevent): BUILD_ENV_VARS += PIP_TRUSTED_HOST=0.0.0.0 PIP_EXTRA_INDEX_URL=http://0.0.0.0:6931/simple
$(call whl,gevent): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo greenlet==3.3.0 > $$F ; echo $$F)
$(call whl,gevent): BUILD_ENV_VARS += GEVENTSETUP_USE_LIBUV=0
$(call whl,gevent): $(call sdist,gevent) $(call sysroot,default) $(call whl,greenlet) build-index-venv
source ./build-index-venv/bin/activate && python3 generate-index.py
# This is dumb, because the server is never stopped...
python3 -m http.server 6931 --directory $(PWD)/dist || true &
$(build_wheel)
$(call sysroot,pycurl): $(call sysroot,python-wheels) $(call tarxz,brotli) $(call tarxz,curl)
$(assemble_sysroot)
$(call targz,pycurl): $(call sysroot,pycurl)
$(call targz,pycurl): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call targz,pycurl): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call targz,pycurl): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call targz,pycurl): BUILD_ENV_VARS += PYCURL_CURL_CONFIG=${PWD}/$(call sysroot,pycurl)/usr/local/bin/curl-config PYCURL_OPENSSL_DIR=${PWD}/$(call sysroot,pycurl)/usr/local PYCURL_LINK_ARG=${PWD}/$(call sysroot,pycurl)/usr/local/lib/wasm32-wasi PYCURL_CURL_DIR=${PWD}/$(call sysroot,pycurl)/usr/local
$(call targz,pycurl): BUILD_EXTRA_FLAGS = -C--curl-config
$(call targz,pycurl): ${MESON_CROSSFILE}
$(call targz,pycurl):
$(build_sdist)
$(call whl,pycurl): $(call sysroot,pycurl)
$(call whl,pycurl): BUILD_ENV_VARS += $(call set_sysroot,pycurl)
$(call whl,pycurl): BUILD_ENV_VARS += PIP_CONSTRAINT=$$(F=$$(mktemp) ; echo numpy==2.4.0.dev0 > $$F ; echo $$F)
$(call whl,pycurl): BUILD_ENV_VARS += PIP_EXTRA_INDEX_URL=https://pythonindex.wasix.org/simple
$(call whl,pycurl): BUILD_ENV_VARS += NUMPY_ONLY_GET_INCLUDE=1
$(call whl,pycurl): BUILD_ENV_VARS += PYCURL_CURL_CONFIG=${PWD}/$(call sysroot,pycurl)/usr/local/bin/curl-config PYCURL_OPENSSL_DIR=${PWD}/$(call sysroot,pycurl)/usr/local PYCURL_LINK_ARG=${PWD}/$(call sysroot,pycurl)/usr/local/lib/wasm32-wasi PYCURL_CURL_DIR=${PWD}/$(call sysroot,pycurl)/usr/local
$(call whl,pycurl): BUILD_EXTRA_FLAGS = -C--curl-config
$(call whl,pycurl): ${MESON_CROSSFILE}
$(call whl,pycurl):
$(build_wheel)
$(call sysroot,cryptography): $(call sysroot,python-wheels) $(call tarxz,openssl)
$(assemble_sysroot)
# Copy openssl wasm32-wasi libs to the general lib dir, because openssl-sys does not look in wasm32-wasi subdir (I think)
cp -r $@/usr/local/lib/wasm32-wasi/* $@/usr/local/lib
$(call targz,cryptography): PREPARE = rustup override set wasix
$(call whl,cryptography): $(call sysroot,cryptography)
$(call whl,cryptography): PREPARE = rustup override set wasix
$(call whl,cryptography): BUILD_ENV_VARS += WASIXCC_SYSROOT=${PWD}/$(call sysroot,cryptography)
$(call whl,cryptography): BUILD_ENV_VARS += WASIXCC_WASM_EXCEPTIONS=yes
$(call whl,cryptography): BUILD_ENV_VARS += WASIXCC_PIC=yes
$(call whl,cryptography): BUILD_ENV_VARS += WASIXCC_SYSROOT=${PWD}/$(call sysroot,cryptography)
# $(call whl,cryptography): BUILD_ENV_VARS += CC_wasm32_wasmer_wasi_dl=wasixcc
# $(call whl,cryptography): BUILD_ENV_VARS += CXX_wasm32_wasmer_wasi_dl=wasix++
# $(call whl,cryptography): BUILD_ENV_VARS += CC=
# $(call whl,cryptography): BUILD_ENV_VARS += CXX=
$(call whl,cryptography): BUILD_ENV_VARS += CARGO_BUILD_TARGET=wasm32-wasmer-wasi-dl
$(call whl,cryptography): BUILD_ENV_VARS += OPENSSL_DIR=${PWD}/$(call sysroot,cryptography)/usr/local
$(call whl,cryptography): BUILD_ENV_VARS += PYO3_CROSS_LIB_DIR=${PWD}/$(call sysroot,cryptography)/usr/local/lib
$(call whl,cryptography): BUILD_ENV_VARS += RUSTFLAGS="-C llvm-args=-wasm-use-legacy-eh=false -C link-arg=-Bsymbolic"
# $(call whl,cryptography): BUILD_ENV_VARS += MATURIN_PEP517_ARGS="" # extra maturin args if needed
$(call whl,cryptography): BUILD_ENV_VARS += _PYTHON_HOST_PLATFORM="wasix_wasm32"
$(call targz,cryptography43-0-3): PREPARE = rustup override set wasix
$(call whl,cryptography43-0-3): $(call sysroot,cryptography)
$(call whl,cryptography43-0-3): PREPARE = rustup override set wasix
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += WASIXCC_SYSROOT=${PWD}/$(call sysroot,cryptography)
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += WASIXCC_WASM_EXCEPTIONS=yes
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += WASIXCC_PIC=yes
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += WASIXCC_SYSROOT=${PWD}/$(call sysroot,cryptography)
# $(call whl,cryptography43-0-3): BUILD_ENV_VARS += CC_wasm32_wasmer_wasi_dl=wasixcc
# $(call whl,cryptography43-0-3): BUILD_ENV_VARS += CXX_wasm32_wasmer_wasi_dl=wasix++
# $(call whl,cryptography43-0-3): BUILD_ENV_VARS += CC=
# $(call whl,cryptography43-0-3): BUILD_ENV_VARS += CXX=
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += CARGO_BUILD_TARGET=wasm32-wasmer-wasi-dl
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += OPENSSL_DIR=${PWD}/$(call sysroot,cryptography)/usr/local
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += PYO3_CROSS_LIB_DIR=${PWD}/$(call sysroot,cryptography)/usr/local/lib
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += RUSTFLAGS="-C llvm-args=-wasm-use-legacy-eh=false -C link-arg=-Bsymbolic"
$(call whl,cryptography43-0-3): BUILD_ENV_VARS += _PYTHON_HOST_PLATFORM="wasix_wasm32"
$(call targz,bcrypt): PREPARE = rustup override set wasix
$(call whl,bcrypt): PREPARE = rustup override set wasix
$(call whl,bcrypt): BUILD_ENV_VARS += WASIXCC_SYSROOT=${PWD}/$(call sysroot,python-wheels)
$(call whl,bcrypt): BUILD_ENV_VARS += WASIXCC_WASM_EXCEPTIONS=yes
$(call whl,bcrypt): BUILD_ENV_VARS += WASIXCC_PIC=yes
$(call whl,bcrypt): BUILD_ENV_VARS += CARGO_BUILD_TARGET=wasm32-wasmer-wasi-dl
$(call whl,bcrypt): BUILD_ENV_VARS += PYO3_CROSS_LIB_DIR=${PWD}/$(call sysroot,python-wheels)/usr/local/lib
$(call whl,bcrypt): BUILD_ENV_VARS += RUSTFLAGS="-C llvm-args=-wasm-use-legacy-eh=false -C link-arg=-Bsymbolic"