File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -872,8 +872,7 @@ $$(PYTHON_STDLIB-$(os)): \
872
872
$$(foreach sdk,$$(SDKS-$(os ) ) ,cp $$(PYTHON_FATSTDLIB-$$(sdk ) ) /lib-dynload/* $$(PYTHON_STDLIB-$(os ) ) /lib-dynload; )
873
873
874
874
dist/Python-$(PYTHON_VER ) -$(os ) -support.$(BUILD_NUMBER ) .tar.gz: $$(PYTHON_XCFRAMEWORK-$(os ) ) $$(PYTHON_STDLIB-$(os ) )
875
- @echo ">>> Create final distribution artefact for $(os ) "
876
- mkdir -p dist
875
+ @echo ">>> Create VERSIONS file for $(os ) "
877
876
echo "Python version: $(PYTHON_VERSION ) " > support/$(os ) /VERSIONS
878
877
echo "Build: $(BUILD_NUMBER ) " >> support/$(os ) /VERSIONS
879
878
echo "Min $(os ) version: $$(VERSION_MIN-$(os ) ) " >> support/$(os ) /VERSIONS
@@ -887,6 +886,17 @@ endif
887
886
echo "OpenSSL: $(OPENSSL_VERSION ) " >> support/$(os ) /VERSIONS
888
887
echo "XZ: $(XZ_VERSION ) " >> support/$(os ) /VERSIONS
889
888
889
+ ifneq ($(os ) ,macOS)
890
+ @echo ">>> Create cross-platform site sitecustomize.py for $(os)"
891
+ mkdir -p support/$(os)/platform-site
892
+ cat $(PROJECT_DIR)/patch/Python/sitecustomize.py \
893
+ | sed -e "s/{{os}}/$(os)/g" \
894
+ | sed -e "s/{{tag}}/$$(shell echo $(os) | tr '[:upper:]' '[:lower:]')_$$(shell echo $$(VERSION_MIN-$(os)) | sed "s/\./_/g")/g" \
895
+ > support/$(os)/platform-site/sitecustomize.py
896
+ endif
897
+
898
+ @echo ">>> Create final distribution artefact for $(os ) "
899
+ mkdir -p dist
890
900
# Build a "full" tarball with all content for test purposes
891
901
tar zcvf dist/Python-$(PYTHON_VER ) -$(os ) -support.test-$(BUILD_NUMBER ) .tar.gz -X patch/Python/test.exclude -C support/$(os ) `ls -A support/$(os ) `
892
902
# Build a distributable tarball
Original file line number Diff line number Diff line change @@ -90,6 +90,17 @@ Each support package contains:
90
90
one for physical devices, and one for the simulator. The simulator binaries
91
91
are "fat", containing code for both x86_64 and arm64.
92
92
93
+ Non-macOS platforms also contain a ``platform-site `` folder. This contains a
94
+ site customization script that can be used to make your local Python install
95
+ look like it is an on-device install. This is needed because when you run
96
+ ``pip `` you'll be on a macOS machine; if ``pip `` tries to install a binary
97
+ package, it will install a macOS binary wheel (which won't work on
98
+ iOS/tvOS/watchOS). However, if you add the ``platform-site `` folder to your
99
+ ``PYTHONPATH `` when invoking pip, the site customization will make your Python
100
+ install return ``platform `` and ``sysconfig `` responses consistent with
101
+ on-device behavior, which will cause ``pip `` to install platform-appropriate
102
+ packages.
103
+
93
104
To add a support package to your own Xcode project:
94
105
95
106
1. Drag ``Python.xcframework `` and ``python-stdlib `` into your Xcode project
Original file line number Diff line number Diff line change
1
+ # A site customization that can be used to trick pip into installing
2
+ # packages cross-platform. If the folder containing this file is on
3
+ # your PYTHONPATH when you invoke pip, pip will behave as if it were
4
+ # running on {{os}}.
5
+ import os
6
+ import platform
7
+ import sys
8
+ import sysconfig
9
+
10
+ # Make platform.system() return "{{os}}"
11
+ def custom_system ():
12
+ return "{{os}}"
13
+
14
+ platform .system = custom_system
15
+
16
+ # Make sysconfig.get_platform() return "{{tag}}"
17
+ def custom_get_platform ():
18
+ return "{{tag}}"
19
+
20
+ sysconfig .get_platform = custom_get_platform
21
+
22
+ # Call the next sitecustomize script if there is one
23
+ # (https://nedbatchelder.com/blog/201001/running_code_at_python_startup.html).
24
+ del sys .modules ["sitecustomize" ]
25
+ this_dir = os .path .dirname (__file__ )
26
+ path_index = sys .path .index (this_dir )
27
+ del sys .path [path_index ]
28
+ try :
29
+ import sitecustomize # noqa: F401
30
+ finally :
31
+ sys .path .insert (path_index , this_dir )
You can’t perform that action at this time.
0 commit comments