@@ -104,6 +104,12 @@ downloads/Python-$(PYTHON_VERSION).tar.gz:
104
104
curl $(CURL_FLAGS ) -o $@ \
105
105
https://www.python.org/ftp/python/$(PYTHON_MICRO_VERSION ) /Python-$(PYTHON_VERSION ) .tgz
106
106
107
+ downloads/python-$(PYTHON_VERSION ) -macos11.pkg :
108
+ @echo " >>> Download macOS Python package"
109
+ mkdir -p downloads
110
+ curl $(CURL_FLAGS ) -o $@ \
111
+ https://www.python.org/ftp/python/$(PYTHON_MICRO_VERSION ) /python-$(PYTHON_VERSION ) -macos11.pkg
112
+
107
113
# ##########################################################################
108
114
# Build for specified target (from $(TARGETS-*))
109
115
# ##########################################################################
@@ -398,146 +404,15 @@ endif
398
404
# Expand the build-target macro for target on this OS
399
405
$$(foreach target,$$(SDK_TARGETS-$(sdk ) ) ,$$(eval $$(call build-target,$$(target ) ,$(os ) ) ) )
400
406
401
- # ##########################################################################
402
- # SDK: Aliases
403
- # ##########################################################################
404
-
405
- support/$(PYTHON_VER ) /$(os ) /bin/$$(TARGET_TRIPLE-$(sdk ) ) -clang:
406
- patch/make-xcrun-alias $$@ "--sdk $(sdk ) clang"
407
-
408
- support/$(PYTHON_VER ) /$(os ) /bin/$$(TARGET_TRIPLE-$(sdk ) ) -cpp:
409
- patch/make-xcrun-alias $$@ "--sdk $(sdk ) clang -E"
410
-
411
- support/$(PYTHON_VER ) /$(os ) /bin/$$(TARGET_TRIPLE-$(sdk ) ) -ar:
412
- patch/make-xcrun-alias $$@ "--sdk $(sdk ) ar"
413
-
414
- # ##########################################################################
415
- # SDK: BZip2
416
- # ##########################################################################
417
-
418
- BZIP2_INSTALL-$(sdk ) =$(PROJECT_DIR ) /install/$(os ) /$(sdk ) /bzip2-$(BZIP2_VERSION )
419
- BZIP2_LIB-$(sdk ) =$$(BZIP2_INSTALL-$(sdk ) ) /lib/libbz2.a
420
-
421
- # This is only used on macOS.
422
- downloads/bzip2-$(BZIP2_VERSION ) -$(sdk ) .tar.gz:
423
- @echo ">>> Download BZip2 for $(sdk ) "
424
- mkdir -p downloads
425
- curl $(CURL_FLAGS ) -o $$@ \
426
- https://github.com/beeware/cpython-macOS-source-deps/releases/download/BZip2-$(BZIP2_VERSION ) /bzip2-$(BZIP2_VERSION ) -$(sdk ) .tar.gz
427
-
428
- $$(BZIP2_LIB-$(sdk ) ) : downloads/bzip2-$(BZIP2_VERSION ) -$(sdk ) .tar.gz
429
- @echo ">>> Install BZip2 for $(sdk ) "
430
- mkdir -p $$(BZIP2_INSTALL-$(sdk ) )
431
- cd $$(BZIP2_INSTALL-$(sdk ) ) && tar zxvf $(PROJECT_DIR ) /downloads/bzip2-$(BZIP2_VERSION ) -$(sdk ) .tar.gz
432
- # Ensure the target is marked as clean.
433
- touch $$(BZIP2_LIB-$(sdk ) )
434
-
435
- # ##########################################################################
436
- # SDK: XZ (LZMA)
437
- # ##########################################################################
438
-
439
- XZ_INSTALL-$(sdk ) =$(PROJECT_DIR ) /install/$(os ) /$(sdk ) /xz-$(XZ_VERSION )
440
- XZ_LIB-$(sdk ) =$$(XZ_INSTALL-$(sdk ) ) /lib/liblzma.a
441
-
442
- # This is only used on macOS.
443
- downloads/xz-$(XZ_VERSION ) -$(sdk ) .tar.gz:
444
- @echo ">>> Download XZ for $(sdk ) "
445
- mkdir -p downloads
446
- curl $(CURL_FLAGS ) -o $$@ \
447
- https://github.com/beeware/cpython-macOS-source-deps/releases/download/XZ-$(XZ_VERSION ) /xz-$(XZ_VERSION ) -$(sdk ) .tar.gz
448
-
449
- $$(XZ_LIB-$(sdk ) ) : downloads/xz-$(XZ_VERSION ) -$(sdk ) .tar.gz
450
- @echo ">>> Install XZ for $(sdk ) "
451
- mkdir -p $$(XZ_INSTALL-$(sdk ) )
452
- cd $$(XZ_INSTALL-$(sdk ) ) && tar zxvf $(PROJECT_DIR ) /downloads/xz-$(XZ_VERSION ) -$(sdk ) .tar.gz
453
- # Ensure the target is marked as clean.
454
- touch $$(XZ_LIB-$(sdk ) )
455
-
456
- # ##########################################################################
457
- # SDK: OpenSSL
458
- # ##########################################################################
459
-
460
- OPENSSL_INSTALL-$(sdk ) =$(PROJECT_DIR ) /install/$(os ) /$(sdk ) /openssl-$(OPENSSL_VERSION )
461
- OPENSSL_SSL_LIB-$(sdk ) =$$(OPENSSL_INSTALL-$(sdk ) ) /lib/libssl.a
462
-
463
- # This is only used on macOS.
464
- downloads/openssl-$(OPENSSL_VERSION ) -$(sdk ) .tar.gz:
465
- @echo ">>> Download OpenSSL for $(sdk ) "
466
- mkdir -p downloads
467
- curl $(CURL_FLAGS ) -o $$@ \
468
- https://github.com/beeware/cpython-macOS-source-deps/releases/download/OpenSSL-$(OPENSSL_VERSION ) /openssl-$(OPENSSL_VERSION ) -$(sdk ) .tar.gz
469
-
470
- $$(OPENSSL_SSL_LIB-$(sdk ) ) : downloads/openssl-$(OPENSSL_VERSION ) -$(sdk ) .tar.gz
471
- @echo ">>> Install OpenSSL for $(sdk ) "
472
- mkdir -p $$(OPENSSL_INSTALL-$(sdk ) )
473
- cd $$(OPENSSL_INSTALL-$(sdk ) ) && tar zxvf $(PROJECT_DIR ) /downloads/openssl-$(OPENSSL_VERSION ) -$(sdk ) .tar.gz
474
- # Ensure the target is marked as clean.
475
- touch $$(OPENSSL_SSL_LIB-$(sdk ) )
476
-
477
407
# ##########################################################################
478
408
# SDK: Python
479
409
# ##########################################################################
480
410
481
- # macOS builds are compiled as a single universal2 build. The fat library is a
482
- # direct copy of OS build, and the headers and standard library are unmodified
483
- # from the versions produced by the OS build.
484
- ifeq ($(os ) ,macOS)
485
-
486
- PYTHON_SRCDIR-$(sdk) =build/$(os ) /$(sdk ) /python-$(PYTHON_VERSION )
487
-
488
- $$(PYTHON_SRCDIR-$(sdk ) ) /configure : \
489
- $$(BZIP2_LIB-$$(sdk)) \
490
- $$(XZ_LIB-$$(sdk)) \
491
- $$(OPENSSL_SSL_LIB-$$(sdk)) \
492
- downloads/Python-$(PYTHON_VERSION).tar.gz
493
- @echo ">>> Unpack and configure Python for $(sdk)"
494
- mkdir -p $$(PYTHON_SRCDIR-$(sdk))
495
- tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(sdk))
496
- # Apply target Python patches
497
- cd $$(PYTHON_SRCDIR-$(sdk)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch
498
- # Touch the configure script to ensure that Make identifies it as up to date.
499
- touch $$(PYTHON_SRCDIR-$(sdk))/configure
500
-
501
- $$(PYTHON_SRCDIR-$(sdk ) ) /Makefile : \
502
- support/$(PYTHON_VER ) /$(os ) /bin/$$(TARGET_TRIPLE-$(sdk ) ) -clang \
503
- support/$(PYTHON_VER ) /$(os ) /bin/$$(TARGET_TRIPLE-$(sdk ) ) -cpp \
504
- $$(PYTHON_SRCDIR-$(sdk ) ) /configure
505
- # Configure target Python
506
- cd $$(PYTHON_SRCDIR-$(sdk ) ) && \
507
- PATH=" $( PROJECT_DIR) /support/$( PYTHON_VER) /$( os) /bin:$( PATH) " \
508
- ./configure \
509
- CC=$$(TARGET_TRIPLE-$(sdk ) ) -clang \
510
- CPP=$$(TARGET_TRIPLE-$(sdk ) ) -cpp \
511
- CFLAGS=" $$ (CFLAGS-$( sdk) )" \
512
- LDFLAGS=" $$ (LDFLAGS-$( sdk) )" \
513
- LIBLZMA_CFLAGS=" -I$$ (XZ_INSTALL-$( sdk) )/include" \
514
- LIBLZMA_LIBS=" -L$$ (XZ_INSTALL-$( sdk) )/lib -llzma" \
515
- BZIP2_CFLAGS=" -I$$ (BZIP2_INSTALL-$( sdk) )/include" \
516
- BZIP2_LIBS=" -L$$ (BZIP2_INSTALL-$( sdk) )/lib -lbz2" \
517
- MACOSX_DEPLOYMENT_TARGET=" $$ (VERSION_MIN-$( os) )" \
518
- --prefix=" $$ (PYTHON_INSTALL-$( sdk) )" \
519
- --enable-ipv6 \
520
- --enable-universalsdk \
521
- --with-openssl=" $$ (OPENSSL_INSTALL-$( sdk) )" \
522
- --with-universal-archs=universal2 \
523
- --without-ensurepip \
524
- 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .config.log
525
-
526
- $$(PYTHON_SRCDIR-$(sdk ) ) /python.exe : $$(PYTHON_SRCDIR-$(sdk ) ) /Makefile
527
- @echo " >>> Build Python for $( sdk) "
528
- cd $$(PYTHON_SRCDIR-$(sdk ) ) && \
529
- PATH=" $( PROJECT_DIR) /support/$( PYTHON_VER) /$( os) /bin:$( PATH) " \
530
- make all \
531
- 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .build.log
532
-
533
- $$(PYTHON_LIB-$(sdk ) ) $$(PYTHON_INCLUDE-$$(sdk ) ) /Python.h $$(PYTHON_STDLIB-$(sdk ) ) /LICENSE.TXT : $$(PYTHON_SRCDIR-$(sdk ) ) /python.exe
534
- @echo " >>> Install Python for $( sdk) "
535
- cd $$(PYTHON_SRCDIR-$(sdk ) ) && \
536
- make install \
537
- 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .install.log
538
-
539
- else
411
+ ifneq ($(os ) ,macOS)
540
412
413
+ # macOS builds are extracted from the official installer package, then
414
+ # reprocessed into an XCFramework.
415
+ #
541
416
# Non-macOS builds need to be merged on a per-SDK basis. The merge covers:
542
417
# * Merging a fat libPython.a
543
418
# * Installing an architecture-sensitive pyconfig.h
@@ -632,6 +507,47 @@ $$(foreach sdk,$$(SDKS-$(os)),$$(eval $$(call build-sdk,$$(sdk),$(os))))
632
507
# Build: Python
633
508
# ##########################################################################
634
509
510
+ ifeq ($(os ) ,macOS)
511
+
512
+ $$(PYTHON_XCFRAMEWORK-$(os ) ) /Info.plist : \
513
+ downloads/python-$(PYTHON_VERSION ) -macos11.pkg
514
+ @echo " >>> Repackage macOS package as XCFramework"
515
+
516
+ # Unpack .pkg file. It turns out .pkg files are readable by tar... although
517
+ # their internal format is a bit of a mess. From tar's perspective, the .pkg
518
+ # is a tarball that contains additional tarballs; the inner tarball has the
519
+ # "payload" that is the framework.
520
+ mkdir -p build/macOS/macosx/python-$(PYTHON_VERSION)
521
+ tar zxf downloads/python-$(PYTHON_VERSION)-macos11.pkg -C build/macOS/macosx/python-$(PYTHON_VERSION)
522
+
523
+ # Unpack payload inside .pkg file
524
+ mkdir -p install/macOS/macosx/python-$(PYTHON_VERSION)/Python.framework
525
+ tar zxf build/macOS/macosx/python-$(PYTHON_VERSION)/Python_Framework.pkgPython_Framework.pkg/PayloadPython_Framework.pkgPython_Framework.pkg/PayloadPython_Framework.pkgPython_Framework.pkg/Payload -C install/macOS/macosx/python-$(PYTHON_VERSION)/Python.framework -X patch/Python/release.macOS.exclude
526
+
527
+ # Remove the signature from the extracted framework
528
+ codesign --remove-signature install/macOS/macosx/python-$(PYTHON_VERSION)/Python.framework
529
+
530
+ # Create XCFramework out of the extracted framework
531
+ xcodebuild -create-xcframework -output $$(PYTHON_XCFRAMEWORK-$(os)) -framework install/macOS/macosx/python-$(PYTHON_VERSION)/Python.framework
532
+
533
+ support/$(PYTHON_VER ) /macOS/VERSIONS :
534
+ @echo " >>> Create VERSIONS file for macOS"
535
+ echo " Python version: $( PYTHON_VERSION) " > support/$(PYTHON_VER ) /macOS/VERSIONS
536
+ echo " Build: $( BUILD_NUMBER) " >> support/$(PYTHON_VER ) /macOS/VERSIONS
537
+ echo " Min macOS version: $$ (VERSION_MIN-macOS)" >> support/$(PYTHON_VER ) /macOS/VERSIONS
538
+
539
+ dist/Python-$(PYTHON_VER ) -macOS-support.$(BUILD_NUMBER ) .tar.gz : \
540
+ $$(PYTHON_XCFRAMEWORK-macOS ) /Info.plist \
541
+ support/$(PYTHON_VER ) /macOS/VERSIONS \
542
+ $$(foreach target,$$(TARGETS-macOS ) , $$(PYTHON_SITECUSTOMIZE-$$(target ) ) )
543
+
544
+ @echo ">>> Create final distribution artefact for macOS"
545
+ mkdir -p dist
546
+ # Build a distributable tarball
547
+ tar zcvf $$@ -C support/$(PYTHON_VER)/macOS `ls -A support/$(PYTHON_VER)/macOS/`
548
+
549
+ else
550
+
635
551
$$(PYTHON_XCFRAMEWORK-$(os ) ) /Info.plist : \
636
552
$$(foreach sdk,$$(SDKS-$(os ) ) ,$$(PYTHON_LIB-$$(sdk ) ) $$(PYTHON_INCLUDE-$$(sdk ) ) /Python.h)
637
553
@echo " >>> Create Python.XCFramework on $( os) "
@@ -666,11 +582,7 @@ $$(PYTHON_STDLIB-$(os))/VERSIONS: \
666
582
echo "Build: $(BUILD_NUMBER)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
667
583
echo "Min $(os) version: $$(VERSION_MIN-$(os))" >> support/$(PYTHON_VER)/$(os)/VERSIONS
668
584
echo "---------------------" >> support/$(PYTHON_VER)/$(os)/VERSIONS
669
- ifeq ($(os ) ,macOS)
670
- echo "libFFI: built-in" >> support/$(PYTHON_VER)/$(os)/VERSIONS
671
- else
672
585
echo "libFFI: $(LIBFFI_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
673
- endif
674
586
echo "BZip2: $(BZIP2_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
675
587
echo "OpenSSL: $(OPENSSL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
676
588
echo "XZ: $(XZ_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
@@ -687,6 +599,8 @@ dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \
687
599
# Build a distributable tarball
688
600
tar zcvf $$@ -X patch/Python/release.common.exclude -X patch/Python/release.$(os).exclude -C support/$(PYTHON_VER)/$(os) `ls -A support/$(PYTHON_VER)/$(os)/`
689
601
602
+ endif
603
+
690
604
clean-$(os ) :
691
605
@echo ">>> Clean Python build products on $(os ) "
692
606
rm -rf \
0 commit comments