Skip to content

Commit

Permalink
Merge pull request #237 from beeware/ios-ver-sitecustom
Browse files Browse the repository at this point in the history
Add ios_ver and _multiarch shims for pip 24.3 support.
  • Loading branch information
freakboy3742 authored Oct 28, 2024
2 parents 0717ddb + 75dd5e3 commit c8da2e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ 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
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator
IS_SIMULATOR-$(target)="True"
endif
endif

Expand Down Expand Up @@ -324,6 +326,9 @@ $$(PYTHON_SITECUSTOMIZE-$(target)):
cat $(PROJECT_DIR)/patch/Python/sitecustomize.$(os).py \
| sed -e "s/{{os}}/$(os)/g" \
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
| sed -e "s/{{version_min}}/$$(VERSION_MIN-$(os))/g" \
| sed -e "s/{{is_simulator}}/$$(IS_SIMULATOR-$(target))/g" \
| sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(SDK-$(target))/g" \
| sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(SDK-$(target))/g" \
> $$(PYTHON_SITECUSTOMIZE-$(target))

Expand Down
17 changes: 16 additions & 1 deletion patch/Python/sitecustomize.iOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# packages cross-platform. If the folder containing this file is on
# your PYTHONPATH when you invoke pip, pip will behave as if it were
# running on {{os}}.
import collections
import distutils.ccompiler
import distutils.unixccompiler
import os
Expand All @@ -16,7 +17,21 @@ def custom_system():

platform.system = custom_system

# Make sysconfig.get_platform() return "{{tag}}"
# Make platform.ios_ver() return an appropriate namedtuple
IOSVersionInfo = collections.namedtuple(
"IOSVersionInfo",
["system", "release", "model", "is_simulator"]
)

def custom_ios_ver(system="", release="", model="", is_simulator=False):
return IOSVersionInfo("{{os}}", "{{version_min}}", "iPhone", {{is_simulator}})

platform.ios_ver = custom_ios_ver

# Make sys.implementation._multiarch return the multiarch description
sys.implementation._multiarch = "{{multiarch}}"

# Make sysconfig.get_platform() return the platform tag
def custom_get_platform():
return "{{tag}}"

Expand Down

0 comments on commit c8da2e9

Please sign in to comment.