@@ -438,7 +438,14 @@ endif
438
438
# macOS builds are compiled as a single universal2 build. As a result,
439
439
# the macOS Python build is configured in the `build` macro, rather than the
440
440
# `build-target` macro.
441
- ifneq ($(os ) ,macOS)
441
+ ifeq ($(os ) ,macOS)
442
+
443
+ # These constants will be the same for all macOS targets
444
+ PYTHON_DIR-$(target) =build/$(os ) /Python-$(PYTHON_VERSION ) -$(os )
445
+ PYTHON_LIB-$(target) =$$(PYTHON_DIR-$(target ) ) /_install/lib/libpython$(PYTHON_VER ) .a
446
+ # PYCONFIG_H-$(target) not defined, as there's no header shim needed
447
+
448
+ else
442
449
443
450
PYTHON_DIR-$(target) =build/$(os ) /Python-$(PYTHON_VERSION ) -$(target )
444
451
PYTHON_LIB-$(target) =$$(PYTHON_DIR-$(target ) ) /_install/lib/libpython$(PYTHON_VER ) .a
@@ -518,7 +525,8 @@ vars-$(target):
518
525
@echo "LIBFFI_DIR-$(target ) : $$(LIBFFI_DIR-$(target ) ) "
519
526
@echo "LIBFFI_LIB-$(target ) : $$(LIBFFI_LIB-$(target ) ) "
520
527
@echo "PYTHON_DIR-$(target ) : $$(PYTHON_DIR-$(target ) ) "
521
- @echo "pyconfig.h-$(target ) : $$(pyconfig.h-$(target ) ) "
528
+ @echo "PYTHON_LIB-$(target ) : $$(PYTHON_LIB-$(target ) ) "
529
+ @echo "PYCONFIG_H-$(target ) : $$(PYCONFIG_H-$(target ) ) "
522
530
@echo
523
531
524
532
endef # build-target
@@ -603,17 +611,23 @@ $$(LIBFFI_FATLIB-$(sdk)): $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(LIBFFI_LIB
603
611
# SDK: Python
604
612
# ##########################################################################
605
613
614
+ PYTHON_DIR-$(sdk ) =build/$(os ) /python/$(sdk )
615
+ PYTHON_FATLIB-$(sdk ) =$$(PYTHON_DIR-$(sdk ) ) /lib/libPython.a
616
+
606
617
ifeq ($(os ) ,macOS)
618
+ # There's a single OS-level build for macOS; the fat library is a direct copy of
619
+ # OS build, and the headers are the unmodifed headers produced by the OS build.
607
620
608
- # There's no SDK-level build; redirect some constants to the OS-level build
609
- PYTHON_DIR-$(sdk) =build/$(os ) /Python-$(PYTHON_VERSION ) -$(os )
610
- PYTHON_FATLIB-$(sdk) =$$(PYTHON_DIR-$(sdk ) ) /_install/lib/libpython$(PYTHON_VER ) .a
621
+ $$(PYTHON_FATLIB-$(sdk ) ) : $$(PYTHON_LIB-$$(firstword $$(SDK_TARGETS-$(sdk ) ) ) )
622
+ @echo " >>> Build Python fat library for $( sdk) "
623
+ # Copy the OS-level library
624
+ mkdir -p build/$(os ) /python/$(sdk ) /lib
625
+ cp $$(PYTHON_LIB-$$(firstword $$(SDK_TARGETS-$(sdk ) ) ) ) $$(PYTHON_FATLIB-$(sdk ) )
626
+ # Copy headers from the OS-level build
627
+ cp -r $$(PYTHON_DIR-$$(firstword $$(SDK_TARGETS-$(sdk ) ) ) ) /_install/include build/$(os ) /python/$(sdk )
611
628
612
629
else
613
630
614
- PYTHON_DIR-$(sdk) =build/$(os ) /python/$(sdk )
615
- PYTHON_FATLIB-$(sdk) =$$(PYTHON_DIR-$(sdk ) ) /lib/libPython.a
616
-
617
631
$$(PYTHON_FATLIB-$(sdk ) ) : $$(foreach target,$$(SDK_TARGETS-$(sdk ) ) ,$$(PYTHON_LIB-$$(target ) ) )
618
632
@echo " >>> Build Python fat library for $( sdk) "
619
633
mkdir -p build/$(os ) /python/$(sdk ) /lib
@@ -764,7 +778,12 @@ ifeq ($(os),macOS)
764
778
# On macOS, there's a single target and a single output dir,
765
779
# rather than a target for each architecture.
766
780
PYTHON_TARGETS-$(os) =macOS
767
- PYTHON_DIR-$(os) =build/$(os ) /Python-$(PYTHON_VERSION ) -$(os )
781
+
782
+ # For convenience on macOS, define an OS-level PYTHON_DIR and PYTHON_LIB.
783
+ # They are proxies of the values set for the first target, since all target
784
+ # constants should have the same value for macOS builds
785
+ PYTHON_DIR-$(os) =$$(PYTHON_DIR-$$(firstword $$(TARGETS-$(os ) ) ) )
786
+ PYTHON_LIB-$(os) =$$(PYTHON_LIB-$$(firstword $$(TARGETS-$(os ) ) ) )
768
787
769
788
$$(PYTHON_DIR-$(os ) ) /Makefile : \
770
789
$$(BZIP2_XCFRAMEWORK-$(os ) ) \
@@ -798,7 +817,7 @@ $$(PYTHON_DIR-$(os))/python.exe: \
798
817
make all \
799
818
2>&1 | tee -a ../python-$(os ) .build.log
800
819
801
- $$(PYTHON_FATLIB-macosx ) : $$(PYTHON_DIR-$(os ) ) /python.exe
820
+ $$(PYTHON_LIB- $( os ) ) : $$(PYTHON_DIR-$(os ) ) /python.exe
802
821
@echo " >>> Install Python for $( os) "
803
822
cd $$(PYTHON_DIR-$(os ) ) && \
804
823
PATH=" $( PROJECT_DIR) /$( PYTHON_DIR-$( os) ) /_install/bin:$( PATH) " \
@@ -817,7 +836,7 @@ $$(PYTHON_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(PYTHON_FATLIB-$$(
817
836
@echo ">>> Create Python.XCFramework on $(os ) "
818
837
mkdir -p $$(PYTHON_XCFRAMEWORK-$(os ) )
819
838
xcodebuild -create-xcframework \
820
- -output $$@ $$(foreach sdk,$$(SDKS-$(os ) ) ,-library $$(PYTHON_FATLIB-$$(sdk ) ) -headers $$(PYTHON_DIR-$$(sdk ) ) /_install/ include/python$(PYTHON_VER ) ) \
839
+ -output $$@ $$(foreach sdk,$$(SDKS-$(os ) ) ,-library $$(PYTHON_FATLIB-$$(sdk ) ) -headers $$(PYTHON_DIR-$$(sdk ) ) /include/python$(PYTHON_VER ) ) \
821
840
2>&1 | tee -a build/$(os ) /python-$(os ) .xcframework.log
822
841
# Copy the standard library from the first target listed
823
842
mkdir -p $$(PYTHON_RESOURCES-$(os ) )
@@ -877,6 +896,7 @@ vars-$(os): $$(foreach target,$$(TARGETS-$(os)),vars-$$(target)) $$(foreach sdk,
877
896
@echo "PYTHON_RESOURCES-$(os ) : $$(PYTHON_RESOURCES-$(os ) ) "
878
897
@echo "PYTHON_TARGETS-$(os ) : $$(PYTHON_TARGETS-$(os ) ) "
879
898
@echo "PYTHON_DIR-$(os ) : $$(PYTHON_DIR-$(os ) ) "
899
+ @echo "PYTHON_LIB-$(os ) : $$(PYTHON_LIB-$(os ) ) "
880
900
@echo
881
901
882
902
endef # build
0 commit comments