Skip to content

Commit a575f27

Browse files
committed
Ensure that host python is same version as build python.
1 parent cd4736b commit a575f27

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,6 @@ jobs:
104104
steps:
105105
- uses: actions/[email protected]
106106

107-
- name: Set up Python
108-
uses: actions/[email protected]
109-
with:
110-
# Appending -dev ensures that we can always build the dev release.
111-
# It's a no-op for versions that have been published.
112-
python-version: ${{ needs.config.outputs.PYTHON_VER }}-dev
113-
# Ensure that we *always* use the latest build, not a cached version.
114-
# It's an edge case, but when a new alpha is released, we need to use it ASAP.
115-
check-latest: true
116-
117107
- name: Build ${{ matrix.target }}
118108
run: |
119109
# Do the build for the requested target.

Makefile

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ VERSION_MIN-watchOS=4.0
5555

5656
# The architecture of the machine doing the build
5757
HOST_ARCH=$(shell uname -m)
58-
HOST_PYTHON=$(shell which python$(PYTHON_VER))
5958

6059
# Force the path to be minimal. This ensures that anything in the user environment
6160
# (in particular, homebrew and user-provided Python installs) aren't inadvertently
@@ -267,6 +266,7 @@ PYTHON_PLATFORM_SITECUSTOMIZE-$(target)=$$(PYTHON_PLATFORM_CONFIG-$(target))/sit
267266

268267
$$(PYTHON_SRCDIR-$(target))/configure: \
269268
downloads/Python-$(PYTHON_VERSION).tar.gz \
269+
$$(PYTHON_HOST-macosx) \
270270
$$(BZIP2_LIB-$(target)) \
271271
$$(LIBFFI_LIB-$(target)) \
272272
$$(MPDECIMAL_LIB-$(target)) \
@@ -286,7 +286,7 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
286286
$$(PYTHON_SRCDIR-$(target))/configure
287287
# Configure target Python
288288
cd $$(PYTHON_SRCDIR-$(target)) && \
289-
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
289+
PATH="$$(PYTHON_HOST_BIN-macosx):$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
290290
./configure \
291291
LIBLZMA_CFLAGS="-I$$(XZ_INSTALL-$(target))/include" \
292292
LIBLZMA_LIBS="-L$$(XZ_INSTALL-$(target))/lib -llzma" \
@@ -298,7 +298,7 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
298298
LIBFFI_LIBS="-L$$(LIBFFI_INSTALL-$(target))/lib -lffi" \
299299
--host=$$(TARGET_TRIPLE-$(target)) \
300300
--build=$(HOST_ARCH)-apple-darwin \
301-
--with-build-python=$(HOST_PYTHON) \
301+
--with-build-python=$(PYTHON_HOST-macosx) \
302302
--enable-ipv6 \
303303
--with-openssl="$$(OPENSSL_INSTALL-$(target))" \
304304
--enable-framework="$$(PYTHON_INSTALL-$(target))" \
@@ -422,6 +422,8 @@ ifeq ($(os),macOS)
422422
# reprocessed into an XCFramework.
423423

424424
PYTHON_INSTALL-$(sdk)=$(PROJECT_DIR)/install/$(os)/$(sdk)/python-$(PYTHON_VERSION)
425+
PYTHON_HOST_BIN-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/installed/Versions/$(PYTHON_VER)/bin
426+
PYTHON_HOST-$(sdk)=$$(PYTHON_HOST_BIN-$(sdk))/python3
425427
PYTHON_FRAMEWORK-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/Python.framework
426428
PYTHON_INSTALL_VERSION-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Versions/$(PYTHON_VER)
427429
PYTHON_LIB-$(sdk)=$$(PYTHON_INSTALL_VERSION-$(sdk))/Python
@@ -519,6 +521,8 @@ vars-$(sdk):
519521
@echo "SDK_SLICE-$(sdk): $$(SDK_SLICE-$(sdk))"
520522
@echo "LDFLAGS-$(sdk): $$(LDFLAGS-$(sdk))"
521523
@echo "PYTHON_INSTALL-$(sdk): $$(PYTHON_INSTALL-$(sdk))"
524+
@echo "PYTHON_HOST_BIN-$(sdk): $$(PYTHON_HOST_BIN-$(sdk))"
525+
@echo "PYTHON_HOST-$(sdk): $$(PYTHON_HOST-$(sdk))"
522526
@echo "PYTHON_FRAMEWORK-$(sdk): $$(PYTHON_FRAMEWORK-$(sdk))"
523527
@echo "PYTHON_LIB-$(sdk): $$(PYTHON_LIB-$(sdk))"
524528
@echo "PYTHON_BIN-$(sdk): $$(PYTHON_BIN-$(sdk))"
@@ -559,19 +563,23 @@ PYTHON_XCFRAMEWORK-$(os)=support/$(PYTHON_VER)/$(os)/Python.xcframework
559563

560564
ifeq ($(os),macOS)
561565

562-
PYTHON_FRAMEWORK-$(os)=$$(PYTHON_INSTALL-$(sdk))/Python.framework
563-
564-
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
565-
downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg
566-
@echo ">>> Repackage macOS package as XCFramework"
567-
566+
build/macOS/macosx/python-$(PYTHON_VERSION)/DistributionDistribution: downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg
568567
# Unpack .pkg file. It turns out .pkg files are readable by tar... although
569568
# their internal format is a bit of a mess. From tar's perspective, the .pkg
570569
# is a tarball that contains additional tarballs; the inner tarball has the
571570
# "payload" that is the framework.
572571
mkdir -p build/macOS/macosx/python-$(PYTHON_VERSION)
573572
tar zxf downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg -C build/macOS/macosx/python-$(PYTHON_VERSION)
574573

574+
$$(PYTHON_HOST-macosx): build/macOS/macosx/python-$(PYTHON_VERSION)/DistributionDistribution
575+
# Unpack payload inside .pkg file
576+
mkdir -p $$(PYTHON_INSTALL-macosx)/installed
577+
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 $$(PYTHON_INSTALL-macosx)/installed
578+
579+
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
580+
build/macOS/macosx/python-$(PYTHON_VERSION)/DistributionDistribution
581+
@echo ">>> Repackage macOS package as XCFramework"
582+
575583
# Unpack payload inside .pkg file
576584
mkdir -p $$(PYTHON_FRAMEWORK-macosx)
577585
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 $$(PYTHON_FRAMEWORK-macosx) -X patch/Python/release.macOS.exclude
@@ -638,7 +646,7 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
638646

639647
ifeq ($(os),iOS)
640648
@echo ">>> Clone testbed project for $(os)"
641-
$(HOST_PYTHON) $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/iOS/testbed clone --framework $$(PYTHON_XCFRAMEWORK-$(os)) support/$(PYTHON_VER)/$(os)/testbed
649+
$$(PYTHON_HOST-macosx) $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$$(firstword $$(SDKS-$(os))))))/iOS/testbed clone --framework $$(PYTHON_XCFRAMEWORK-$(os)) support/$(PYTHON_VER)/$(os)/testbed
642650
endif
643651

644652
@echo ">>> Create VERSIONS file for $(os)"
@@ -707,7 +715,6 @@ endef # build
707715
vars: $(foreach os,$(OS_LIST),vars-$(os))
708716
@echo ">>> Environment variables for $(os)"
709717
@echo "HOST_ARCH: $(HOST_ARCH)"
710-
@echo "HOST_PYTHON: $(HOST_PYTHON)"
711718
@echo
712719

713720
config:

0 commit comments

Comments
 (0)