-
-
Notifications
You must be signed in to change notification settings - Fork 205
Add Mac Catalyst support #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
74748f5
955cc58
f85e613
e818033
44529bf
4904b76
072bfd7
f8efec4
4e9e3c6
3d417c5
3ea598f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ 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+") | ||
| PYTHON_VER=$(basename $(PYTHON_VERSION)) | ||
| PYTHON_PATCHED_VERSION=$(PYTHON_VER)-patched | ||
|
|
||
| # The binary releases of dependencies, published at: | ||
| # https://github.com/beeware/cpython-apple-source-deps/releases | ||
|
|
@@ -35,15 +36,15 @@ XZ_VERSION=5.6.4-1 | |
| # Supported OS | ||
| OS_LIST=macOS iOS tvOS watchOS | ||
|
|
||
| CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar | ||
| CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar -L | ||
|
|
||
| # macOS targets | ||
| TARGETS-macOS=macosx.x86_64 macosx.arm64 | ||
| VERSION_MIN-macOS=11.0 | ||
|
|
||
| # iOS targets | ||
| TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64 | ||
| VERSION_MIN-iOS=13.0 | ||
| TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64 maccatalyst.x86_64 maccatalyst.arm64 | ||
| VERSION_MIN-iOS=14.2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with the cpython-apple-source-deps repo, this should likely be configured as a separate
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the MacCatalyst target as suggested |
||
|
|
||
| # tvOS targets | ||
| TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64 | ||
|
|
@@ -86,7 +87,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 -D v$(PYTHON_VERSION) $(PYTHON_PATCHED_VERSION) \ | ||
| | 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 | ||
|
|
@@ -117,26 +118,44 @@ downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg: | |
| # | ||
| ########################################################################### | ||
| define build-target | ||
|
|
||
| target=$1 | ||
| os=$2 | ||
|
|
||
| OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') | ||
|
|
||
| # $(target) can be broken up into is composed of $(SDK).$(ARCH) | ||
| SDK-$(target)=$$(basename $(target)) | ||
| SDK-$(target)=$$(subst maccatalyst,macosx,$$(basename $(target))) | ||
| ARCH-$(target)=$$(subst .,,$$(suffix $(target))) | ||
|
|
||
| ifneq ($(os),macOS) | ||
| ifeq ($$(findstring simulator,$$(SDK-$(target))),) | ||
| TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os)) | ||
| IS_SIMULATOR-$(target)=False | ||
| else | ||
| ifneq ($$(findstring simulator,$$(SDK-$(target))),) | ||
| TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator | ||
| IS_SIMULATOR-$(target)=True | ||
| IS_SIMULATOR-$(target)="True" | ||
| TARGET_ABI-$(target)="" | ||
| TARGET_TRIPLE_SUFFIX-$(target)="" | ||
| else ifneq ($$(findstring maccatalyst,$$(target)),) | ||
| TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-ios$$(VERSION_MIN-$(os))-macabi | ||
| IS_SIMULATOR-$(target)="False" | ||
| TARGET_ABI-$(target)="macabi" | ||
| TARGET_TRIPLE_SUFFIX-$(target)="-macabi" | ||
| else | ||
| TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os)) | ||
| IS_SIMULATOR-$(target)="False" | ||
| TARGET_ABI-$(target)="" | ||
| TARGET_TRIPLE_SUFFIX-$(target)="" | ||
| endif | ||
| endif | ||
|
|
||
| SDK_ROOT-$(target)=$$(shell xcrun --sdk $$(SDK-$(target)) --show-sdk-path) | ||
| CC-$(target)=$$(subst $$(VERSION_MIN-$(os)),,$$(TARGET_TRIPLE-$(target))-clang) | ||
| CXX-$(target)=$$(subst $$(VERSION_MIN-$(os)),,$$(TARGET_TRIPLE-$(target))-clang++) | ||
| CFLAGS-$(target)=\ | ||
| --sysroot=$$(SDK_ROOT-$(target)) \ | ||
| $$(CFLAGS-$(os)) | ||
| LDFLAGS-$(target)=\ | ||
| -isysroot $$(SDK_ROOT-$(target)) \ | ||
| $$(CFLAGS-$(os)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these options needed? The CPython makefile should be setting all these correctly
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's required when building C++ targets in mobile-forge (e.g. numpy). Without this I wasn't able to get that to compile. However, let me double check on this and confirm once I've addressed the other comments.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's C++ targets that are the problem, that seems more likely due to either (a) the clang++ shims not existing, or (b) the clang++ shims not being on the path when mobile-forge is running.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you were correct, I've resolved this issue now with the correct configuration of the shims |
||
|
|
||
| ########################################################################### | ||
| # Target: BZip2 | ||
|
|
@@ -286,8 +305,13 @@ $$(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)/support/$(PYTHON_VER)/$(os)/Tools:$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \ | ||
| ./configure \ | ||
| CC="$$(CC-$(target))" \ | ||
| CXX="$$(CXX-$(target))" \ | ||
| CPP="$$(CXX-$(target)) -E" \ | ||
| CFLAGS="$$(CFLAGS-$(target))" \ | ||
| LDFLAGS="$$(LDFLAGS-$(target))" \ | ||
| LIBLZMA_CFLAGS="-I$$(XZ_INSTALL-$(target))/include" \ | ||
| LIBLZMA_LIBS="-L$$(XZ_INSTALL-$(target))/lib -llzma" \ | ||
| BZIP2_CFLAGS="-I$$(BZIP2_INSTALL-$(target))/include" \ | ||
|
|
@@ -308,14 +332,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)/support/$(PYTHON_VER)/$(os)/Tools:$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(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)/support/$(PYTHON_VER)/$(os)/Tools:$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \ | ||
| make install \ | ||
| 2>&1 | tee -a ../python-$(PYTHON_VERSION).install.log | ||
|
|
||
|
|
@@ -342,16 +366,23 @@ $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)): | |
| | sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \ | ||
| | sed -e "s/{{version_min}}/$$(VERSION_MIN-$(os))/g" \ | ||
| | sed -e "s/{{is_simulator}}/$$(IS_SIMULATOR-$(target))/g" \ | ||
| | sed -e "s/{{abi}}/$$(TARGET_ABI-$(target))/g" \ | ||
| | sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(subst macosx,iphoneos,$$(SDK-$(target)))$$(TARGET_TRIPLE_SUFFIX-$(target))/g" \ | ||
| | sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(subst macosx,iphoneos-macabi,$$(SDK-$(target)))/g" \ | ||
| > $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_$$(ARCH-$(target))_$$(SDK-$(target)).py | ||
| cat $(PROJECT_DIR)/patch/Python/sitecustomize.py.tmpl \ | ||
| | sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \ | ||
| | sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \ | ||
| | sed -e "s/{{abi}}/$$(TARGET_ABI-$(target))/g" \ | ||
| | sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(subst macosx,iphoneos,$$(SDK-$(target)))$$(TARGET_TRIPLE_SUFFIX-$(target))/g" \ | ||
| | sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(subst macosx,iphoneos-macabi,$$(SDK-$(target)))/g" \ | ||
| > $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) | ||
|
|
||
| endif | ||
|
|
||
| $(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target)) | ||
|
|
||
|
|
||
| ########################################################################### | ||
| # Target: Debug | ||
| ########################################################################### | ||
|
|
@@ -403,10 +434,13 @@ OS_LOWER-$(sdk)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') | |
| SDK_TARGETS-$(sdk)=$$(filter $(sdk).%,$$(TARGETS-$(os))) | ||
| SDK_ARCHES-$(sdk)=$$(sort $$(subst .,,$$(suffix $$(SDK_TARGETS-$(sdk))))) | ||
|
|
||
| ifeq ($$(findstring simulator,$(sdk)),) | ||
| SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g") | ||
| else | ||
| ifneq ($$(findstring simulator,$(sdk)),) | ||
| SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-simulator | ||
| else ifneq ($$(findstring maccatalyst,$(sdk)),) | ||
| SDK_SLICE-$(sdk)=ios-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-maccatalyst | ||
| sdk=macosx | ||
| else | ||
| SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g") | ||
| endif | ||
|
|
||
| # Expand the build-target macro for target on this OS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make this change? The variable is used exactly once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted