Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ on:
XZ_VERSION:
description: "The XZ version used for the build."
value: ${{ jobs.config.outputs.XZ_VERSION }}
ZSTD_VERSION:
description: "The Zstandard version used for the build."
value: ${{ jobs.config.outputs.ZSTD_VERSION }}

env:
FORCE_COLOR: "1"
Expand All @@ -54,6 +57,7 @@ jobs:
MPDECIMAL_VERSION: ${{ steps.extract.outputs.MPDECIMAL_VERSION }}
OPENSSL_VERSION: ${{ steps.extract.outputs.OPENSSL_VERSION }}
XZ_VERSION: ${{ steps.extract.outputs.XZ_VERSION }}
ZSTD_VERSION: ${{ steps.extract.outputs.ZSTD_VERSION }}

steps:
- uses: actions/checkout@v5
Expand All @@ -68,6 +72,7 @@ jobs:
MPDECIMAL_VERSION=$(make config | grep "MPDECIMAL_VERSION=" | cut -d "=" -f 2)
OPENSSL_VERSION=$(make config | grep "OPENSSL_VERSION=" | cut -d "=" -f 2)
XZ_VERSION=$(make config | grep "XZ_VERSION=" | cut -d "=" -f 2)
ZSTD_VERSION=$(make config | grep "ZSTD_VERSION=" | cut -d "=" -f 2)
if [ -z "${{ inputs.build-number }}" ]; then
BUILD_NUMBER=custom
else
Expand All @@ -82,6 +87,7 @@ jobs:
echo "MPDECIMAL_VERSION=${MPDECIMAL_VERSION}" | tee -a ${GITHUB_OUTPUT}
echo "OPENSSL_VERSION=${OPENSSL_VERSION}" | tee -a ${GITHUB_OUTPUT}
echo "XZ_VERSION=${XZ_VERSION}" | tee -a ${GITHUB_OUTPUT}
echo "ZSTD_VERSION=${ZSTD_VERSION}" | tee -a ${GITHUB_OUTPUT}

build:
runs-on: macOS-15
Expand Down Expand Up @@ -184,16 +190,16 @@ jobs:

cpython-testbed:
name: CPython testbed (${{ matrix.platform }})
# For now, CPython testbed can't run on macos-15: https://github.com/actions/runner-images/issues/12777
runs-on: macOS-14
runs-on: macOS-15
needs: [ config, build ]
strategy:
fail-fast: false
matrix:
platform: ["iOS", "visionOS"]
platform: ["iOS", "tvOS", "visionOS"]
include:
- platform: "iOS"
testbed-args: '--simulator "iPhone 16e,arch=arm64,OS=18.5"'
# Needed to disambiguate simulator options.
- platform: "visionOS"
testbed-args: '--simulator "Apple Vision Pro,arch=arm64,OS=2.5"'

steps:
- uses: actions/checkout@v5
Expand Down Expand Up @@ -231,7 +237,7 @@ jobs:
# - test_os as a test of system library calls
# - test_bz2 as a simple test of third party libraries
# - test_ctypes as a test of FFI
python -m testbed run -- test --single-process --rerun -W test_builtin test_grammar test_os test_bz2 test_ctypes
python -m testbed run --verbose ${{ matrix.testbed-args }} -- test --single-process --rerun -W test_builtin test_grammar test_os test_bz2 test_ctypes

crossenv-test:
name: Cross-platform env test (${{ matrix.multiarch }})
Expand Down
60 changes: 46 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BUILD_NUMBER=custom
# of a release cycle, as official binaries won't be published.
# PYTHON_MICRO_VERSION is the full version number, without any alpha/beta/rc suffix. (e.g., 3.10.0)
# PYTHON_VER is the major/minor version (e.g., 3.10)
PYTHON_VERSION=3.14.0rc1
PYTHON_VERSION=3.14.0rc3
PYTHON_PKG_VERSION=$(PYTHON_VERSION)
PYTHON_MICRO_VERSION=$(shell echo $(PYTHON_VERSION) | grep -Eo "\d+\.\d+\.\d+")
PYTHON_PKG_MICRO_VERSION=$(shell echo $(PYTHON_PKG_VERSION) | grep -Eo "\d+\.\d+\.\d+")
Expand All @@ -32,6 +32,7 @@ LIBFFI_VERSION=3.4.7-2
MPDECIMAL_VERSION=4.0.0-2
OPENSSL_VERSION=3.0.16-2
XZ_VERSION=5.6.4-2
ZSTD_VERSION=1.5.7-1

# Supported OS
OS_LIST=macOS iOS tvOS watchOS visionOS
Expand All @@ -41,25 +42,30 @@ CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar
# macOS targets
TARGETS-macOS=macosx.x86_64 macosx.arm64
TRIPLE_OS-macOS=macos
PLATFORM_NAME-macOS=macOS
VERSION_MIN-macOS=11.0

# iOS targets
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
TRIPLE_OS-iOS=ios
PLATFORM_NAME-iOS=iOS
VERSION_MIN-iOS=13.0

# tvOS targets
TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
TRIPLE_OS-tvOS=tvos
PLATFORM_NAME-tvOS=tvOS
VERSION_MIN-tvOS=12.0

# watchOS targets
TARGETS-watchOS=watchsimulator.x86_64 watchsimulator.arm64 watchos.arm64_32
TRIPLE_OS-watchOS=watchos
PLATFORM_NAME-watchOS=watchOS
VERSION_MIN-watchOS=4.0

TARGETS-visionOS=xrsimulator.arm64 xros.arm64
TRIPLE_OS-visionOS=xros
PLATFORM_NAME-visionOS=xrOS
VERSION_MIN-visionOS=2.0

# The architecture of the machine doing the build
Expand Down Expand Up @@ -95,7 +101,7 @@ update-patch:
# call
if [ -z "$(PYTHON_REPO_DIR)" ]; then echo "\n\nPYTHON_REPO_DIR must be set to the root of your Python github checkout\n\n"; fi
cd $(PYTHON_REPO_DIR) && \
git diff -D v$(PYTHON_VERSION) $(PYTHON_VER)-patched \
git diff --no-renames -D v$(PYTHON_VERSION) $(PYTHON_VER)-patched \
| PATH="/usr/local/bin:/opt/homebrew/bin:$(PATH)" filterdiff \
-X $(PROJECT_DIR)/patch/Python/diff.exclude -p 1 --clean \
> $(PROJECT_DIR)/patch/Python/Python.patch
Expand Down Expand Up @@ -187,6 +193,26 @@ $$(XZ_LIB-$(target)): downloads/xz-$(XZ_VERSION)-$(target).tar.gz
# Ensure the target is marked as clean.
touch $$(XZ_LIB-$(target))

###########################################################################
# Target: zstd (ZStandard)
###########################################################################

ZSTD_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/zstd-$(ZSTD_VERSION)
ZSTD_LIB-$(target)=$$(ZSTD_INSTALL-$(target))/lib/libzstd.a

downloads/zstd-$(ZSTD_VERSION)-$(target).tar.gz:
@echo ">>> Download zstd for $(target)"
mkdir -p downloads
curl $(CURL_FLAGS) -o $$@ \
https://github.com/beeware/cpython-apple-source-deps/releases/download/zstd-$(ZSTD_VERSION)/zstd-$(ZSTD_VERSION)-$(target).tar.gz

$$(ZSTD_LIB-$(target)): downloads/zstd-$(ZSTD_VERSION)-$(target).tar.gz
@echo ">>> Install zstd for $(target)"
mkdir -p $$(ZSTD_INSTALL-$(target))
cd $$(ZSTD_INSTALL-$(target)) && tar zxvf $(PROJECT_DIR)/downloads/zstd-$(ZSTD_VERSION)-$(target).tar.gz --exclude="*.dylib"
# Ensure the target is marked as clean.
touch $$(ZSTD_LIB-$(target))

###########################################################################
# Target: mpdecimal
###########################################################################
Expand Down Expand Up @@ -280,22 +306,23 @@ $$(PYTHON_SRCDIR-$(target))/configure: \
$$(LIBFFI_LIB-$(target)) \
$$(MPDECIMAL_LIB-$(target)) \
$$(OPENSSL_SSL_LIB-$(target)) \
$$(XZ_LIB-$(target))
$$(XZ_LIB-$(target)) \
$$(ZSTD_LIB-$(target))
@echo ">>> Unpack and configure Python for $(target)"
mkdir -p $$(PYTHON_SRCDIR-$(target))
tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(target))
# Apply target Python patches
cd $$(PYTHON_SRCDIR-$(target)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch
# Make sure the binary scripts are executable
chmod 755 $$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin/*
chmod 755 $$(PYTHON_SRCDIR-$(target))/Apple/$(os)/Resources/bin/*
# Touch the configure script to ensure that Make identifies it as up to date.
touch $$(PYTHON_SRCDIR-$(target))/configure

$$(PYTHON_SRCDIR-$(target))/Makefile: \
$$(PYTHON_SRCDIR-$(target))/configure
# Configure target Python
cd $$(PYTHON_SRCDIR-$(target)) && \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/Apple/$(os)/Resources/bin:$(PATH)" \
./configure \
LIBLZMA_CFLAGS="-I$$(XZ_INSTALL-$(target))/include" \
LIBLZMA_LIBS="-L$$(XZ_INSTALL-$(target))/lib -llzma" \
Expand All @@ -305,6 +332,8 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
LIBMPDEC_LIBS="-L$$(MPDECIMAL_INSTALL-$(target))/lib -lmpdec" \
LIBFFI_CFLAGS="-I$$(LIBFFI_INSTALL-$(target))/include" \
LIBFFI_LIBS="-L$$(LIBFFI_INSTALL-$(target))/lib -lffi" \
LIBZSTD_CFLAGS="-I$$(ZSTD_INSTALL-$(target))/include" \
LIBZSTD_LIBS="-L$$(ZSTD_INSTALL-$(target))/lib -lzstd" \
--host=$$(TARGET_TRIPLE-$(target)) \
--build=$(HOST_ARCH)-apple-darwin \
--with-build-python=$(HOST_PYTHON) \
Expand All @@ -317,14 +346,14 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
$$(PYTHON_SRCDIR-$(target))/python.exe: $$(PYTHON_SRCDIR-$(target))/Makefile
@echo ">>> Build Python for $(target)"
cd $$(PYTHON_SRCDIR-$(target)) && \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/Apple/$(os)/Resources/bin:$(PATH)" \
make -j8 all \
2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log

$$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe
@echo ">>> Install Python for $(target)"
cd $$(PYTHON_SRCDIR-$(target)) && \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/Apple/$(os)/Resources/bin:$(PATH)" \
make install \
2>&1 | tee -a ../python-$(PYTHON_VERSION).install.log

Expand Down Expand Up @@ -490,15 +519,11 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
mkdir -p $$(PYTHON_INSTALL-$(sdk))/include
ln -si ../Python.framework/Headers $$(PYTHON_INSTALL-$(sdk))/include/python$(PYTHON_VER)

ifeq ($(os), visionOS)
echo "Skipping arch-specific header copying for visionOS"
else
# Add the individual headers from each target in an arch-specific name
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INCLUDE-$$(target))/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig-$$(ARCH-$$(target)).h; )

# Copy the cross-target header from the source folder of the first target in the $(sdk) SDK
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
endif
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/Apple/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h


$$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-$(sdk))/Info.plist $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))
Expand Down Expand Up @@ -666,6 +691,11 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
-output $$(PYTHON_XCFRAMEWORK-$(os)) $$(foreach sdk,$$(SDKS-$(os)),-framework $$(PYTHON_FRAMEWORK-$$(sdk))) \
2>&1 | tee -a support/$(PYTHON_VER)/python-$(os).xcframework.log

@echo ">>> Install build tools for $(os)"
mkdir $$(PYTHON_XCFRAMEWORK-$(os))/build
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/Apple/testbed/Python.xcframework/build/utils.sh $$(PYTHON_XCFRAMEWORK-$(os))/build
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/Apple/testbed/Python.xcframework/build/$$(PLATFORM_NAME-$(os))-dylib-Info-template.plist $$(PYTHON_XCFRAMEWORK-$(os))/build

@echo ">>> Install PYTHONHOME for $(os)"
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/include $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/bin $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
Expand All @@ -674,9 +704,9 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
# Disable dSYM production (for now)
# $$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/Python.dSYM $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )

ifeq ($(filter $(os),iOS visionOS),$(os))
ifeq ($(filter $(os),iOS tvOS visionOS),$(os))
@echo ">>> Clone testbed project for $(os)"
$(HOST_PYTHON) $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/$(os)/testbed clone --framework $$(PYTHON_XCFRAMEWORK-$(os)) support/$(PYTHON_VER)/$(os)/testbed
$(HOST_PYTHON) $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/Apple/testbed clone --platform $(os) --framework $$(PYTHON_XCFRAMEWORK-$(os)) support/$(PYTHON_VER)/$(os)/testbed
endif

@echo ">>> Create VERSIONS file for $(os)"
Expand All @@ -689,6 +719,7 @@ endif
echo "mpdecimal: $(MPDECIMAL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
echo "OpenSSL: $(OPENSSL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
echo "XZ: $(XZ_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
echo "Zstandard: $(ZSTD_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS

dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist \
Expand Down Expand Up @@ -757,6 +788,7 @@ config:
@echo "MPDECIMAL_VERSION=$(MPDECIMAL_VERSION)"
@echo "OPENSSL_VERSION=$(OPENSSL_VERSION)"
@echo "XZ_VERSION=$(XZ_VERSION)"
@echo "ZSTD_VERSION=$(ZSTD_VERSION)"

# Expand cross-platform build and clean targets for each output product
clean: $(foreach os,$(OS_LIST),clean-$(os))
Expand Down
Loading