Skip to content

Commit 2d809f3

Browse files
committed
add logic for building macOS
1 parent 1274694 commit 2d809f3

File tree

3 files changed

+129
-73
lines changed

3 files changed

+129
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ support
1212
__pycache__
1313
tests/testbed/macOS
1414
tests/testbed/iOS
15+
aux
1516
*.log
1617
*.gz
1718
*.DS_Store

Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ VERSION_MIN-visionOS=2.0
6464

6565
# The architecture of the machine doing the build
6666
HOST_ARCH=$(shell uname -m)
67-
HOST_PYTHON=$(shell which python$(PYTHON_VER))
6867

6968
# Force the path to be minimal. This ensures that anything in the user environment
7069
# (in particular, homebrew and user-provided Python installs) aren't inadvertently
@@ -116,6 +115,27 @@ downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg:
116115
curl $(CURL_FLAGS) -o $@ \
117116
https://www.python.org/ftp/python/$(PYTHON_PKG_MICRO_VERSION)/python-$(PYTHON_PKG_VERSION)-macos11.pkg
118117

118+
119+
###########################################################################
120+
# Setup: Python as a Dependency
121+
###########################################################################
122+
123+
# In addition, a macOS build Python for the current architecture is
124+
# also generated here; those won't need fancy dependencies just to
125+
# build another Python. We need this because sometimes, the patches
126+
# are so dramatic that a Python of the same MAJOR.MINOR on our system
127+
# is no longer applicable.
128+
HOST_PYTHON_INSTALL=$(PROJECT_DIR)/aux/hostpython/install
129+
HOST_PYTHON=$(HOST_PYTHON_INSTALL)/bin/python3.14
130+
HOST_PYTHON_SRCDIR=$(PROJECT_DIR)/aux/hostpython/src
131+
$(HOST_PYTHON): downloads/Python-$(PYTHON_VERSION).tar.gz
132+
mkdir -p $(HOST_PYTHON_INSTALL)
133+
mkdir -p $(HOST_PYTHON_SRCDIR)
134+
tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $(HOST_PYTHON_SRCDIR)
135+
cd $(HOST_PYTHON_SRCDIR) && ./configure --prefix="$(HOST_PYTHON_INSTALL)" \
136+
| tee -a ../python-$(PYTHON_VERSION).config.log && make && make install
137+
138+
119139
###########################################################################
120140
# Build for specified target (from $(TARGETS-*))
121141
###########################################################################
@@ -291,7 +311,7 @@ $$(PYTHON_SRCDIR-$(target))/configure: \
291311
# Touch the configure script to ensure that Make identifies it as up to date.
292312
touch $$(PYTHON_SRCDIR-$(target))/configure
293313

294-
$$(PYTHON_SRCDIR-$(target))/Makefile: \
314+
$$(PYTHON_SRCDIR-$(target))/Makefile: $(HOST_PYTHON) \
295315
$$(PYTHON_SRCDIR-$(target))/configure
296316
# Configure target Python
297317
cd $$(PYTHON_SRCDIR-$(target)) && \
@@ -647,7 +667,7 @@ dist/Python-$(PYTHON_VER)-macOS-support.$(BUILD_NUMBER).tar.gz: \
647667

648668
else
649669

650-
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
670+
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: $(HOST_PYTHON) \
651671
$$(foreach sdk,$$(SDKS-$(os)),$$(PYTHON_STDLIB-$$(sdk))/LICENSE.TXT)
652672
@echo ">>> Create Python.XCFramework on $(os)"
653673
mkdir -p $$(dir $$(PYTHON_XCFRAMEWORK-$(os)))

0 commit comments

Comments
 (0)