@@ -129,10 +129,10 @@ ARCH-$(target)=$$(subst .,,$$(suffix $(target)))
129129ifneq ($(os ) ,macOS)
130130 ifeq ($$(findstring simulator,$$(SDK-$(target))),)
131131TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(OS_LOWER-$(target ) )$$(VERSION_MIN-$(os ) )
132- IS_SIMULATOR-$(target) =" False"
132+ IS_SIMULATOR-$(target) =False
133133 else
134134TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(OS_LOWER-$(target ) )$$(VERSION_MIN-$(os ) ) -simulator
135- IS_SIMULATOR-$(target) =" True"
135+ IS_SIMULATOR-$(target) =True
136136 endif
137137endif
138138
@@ -261,6 +261,9 @@ PYTHON_LIB-$(target)=$$(PYTHON_FRAMEWORK-$(target))/Python
261261PYTHON_BIN-$(target) =$$(PYTHON_INSTALL-$(target ) ) /bin
262262PYTHON_INCLUDE-$(target) =$$(PYTHON_FRAMEWORK-$(target ) ) /Headers
263263PYTHON_STDLIB-$(target) =$$(PYTHON_INSTALL-$(target ) ) /lib/python$(PYTHON_VER )
264+ PYTHON_PLATFORM_CONFIG-$(target) =$$(PYTHON_INSTALL-$(target ) ) /platform-config/$$(ARCH-$(target ) ) -$$(SDK-$(target ) )
265+ PYTHON_PLATFORM_SITECUSTOMIZE-$(target) =$$(PYTHON_PLATFORM_CONFIG-$(target ) ) /sitecustomize.py
266+
264267
265268$$(PYTHON_SRCDIR-$(target ) ) /configure : \
266269 downloads/Python-$(PYTHON_VERSION ) .tar.gz \
@@ -319,23 +322,35 @@ $$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe
319322 # Remove any .orig files produced by the compliance patching process
320323 find $$(PYTHON_INSTALL-$(target)) -name "*.orig" -exec rm {} \;
321324
322- endif
323-
324- PYTHON_SITECUSTOMIZE-$(target ) =$(PROJECT_DIR ) /support/$(PYTHON_VER ) /$(os ) /platform-site/$(target ) /sitecustomize.py
325325
326- $$(PYTHON_SITECUSTOMIZE-$(target ) ) :
327- @echo ">>> Create cross-platform sitecustomize.py for $(target ) "
328- mkdir -p $$(dir $$(PYTHON_SITECUSTOMIZE-$(target ) ) )
329- cat $(PROJECT_DIR ) /patch/Python/sitecustomize.$(os ) .py \
326+ $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target ) ) :
327+ @echo " >>> Create cross-plaform config for $( target) "
328+ mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(target ) )
329+ # Create the cross-platform site definition
330+ echo " import _cross_$$ (ARCH-$( target) )_$$ (SDK-$( target) ); import _cross_venv;" \
331+ > $$(PYTHON_PLATFORM_CONFIG-$(target ) ) /_cross_venv.pth
332+ cp $(PROJECT_DIR ) /patch/Python/make_cross_venv.py \
333+ $$(PYTHON_PLATFORM_CONFIG-$(target ) ) /make_cross_venv.py
334+ cp $(PROJECT_DIR ) /patch/Python/_cross_venv.py \
335+ $$(PYTHON_PLATFORM_CONFIG-$(target ) ) /_cross_venv.py
336+ cp $$(PYTHON_STDLIB-$(target ) ) /_sysconfig* \
337+ $$(PYTHON_PLATFORM_CONFIG-$(target ) )
338+ cat $(PROJECT_DIR ) /patch/Python/_cross_target.py.tmpl \
330339 | sed -e " s/{{os}}/$( os) /g" \
340+ | sed -e " s/{{platform}}/$$ (OS_LOWER-$( target) )/g" \
331341 | sed -e " s/{{arch}}/$$ (ARCH-$( target) )/g" \
342+ | sed -e " s/{{sdk}}/$$ (SDK-$( target) )/g" \
332343 | sed -e " s/{{version_min}}/$$ (VERSION_MIN-$( os) )/g" \
333344 | sed -e " s/{{is_simulator}}/$$ (IS_SIMULATOR-$( target) )/g" \
334- | sed -e "s/{{multiarch}}/$$(ARCH-$(target ) ) -$$(SDK-$(target ) ) /g" \
335- | sed -e "s/{{tag}}/$$(OS_LOWER-$(target ) ) -$$(VERSION_MIN-$(os ) ) -$$(ARCH-$(target ) ) -$$(SDK-$(target ) ) /g" \
336- > $$(PYTHON_SITECUSTOMIZE-$(target ) )
345+ > $$(PYTHON_PLATFORM_CONFIG-$(target ) ) /_cross_$$(ARCH-$(target ) ) _$$(SDK-$(target ) ) .py
346+ cat $(PROJECT_DIR ) /patch/Python/sitecustomize.py.tmpl \
347+ | sed -e " s/{{arch}}/$$ (ARCH-$( target) )/g" \
348+ | sed -e " s/{{sdk}}/$$ (SDK-$( target) )/g" \
349+ > $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target ) )
337350
338- $(target ) : $$(PYTHON_SITECUSTOMIZE-$(target ) ) $$(PYTHON_LIB-$(target ) )
351+ endif
352+
353+ $(target ) : $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target ) ) $$(PYTHON_LIB-$(target ) )
339354
340355# ##########################################################################
341356# Target: Debug
@@ -364,6 +379,8 @@ vars-$(target):
364379 @echo "PYTHON_BIN-$(target ) : $$(PYTHON_BIN-$(target ) ) "
365380 @echo "PYTHON_INCLUDE-$(target ) : $$(PYTHON_INCLUDE-$(target ) ) "
366381 @echo "PYTHON_STDLIB-$(target ) : $$(PYTHON_STDLIB-$(target ) ) "
382+ @echo "PYTHON_PLATFORM_CONFIG-$(target ) : $$(PYTHON_PLATFORM_CONFIG-$(target ) ) "
383+ @echo "PYTHON_PLATFORM_SITECUSTOMIZE-$(target ) : $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target ) ) "
367384 @echo
368385
369386endef # build-target
@@ -424,6 +441,7 @@ PYTHON_LIB-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Python
424441PYTHON_BIN-$(sdk) =$$(PYTHON_INSTALL-$(sdk ) ) /bin
425442PYTHON_INCLUDE-$(sdk) =$$(PYTHON_FRAMEWORK-$(sdk ) ) /Headers
426443PYTHON_STDLIB-$(sdk) =$$(PYTHON_INSTALL-$(sdk ) ) /lib/python$(PYTHON_VER )
444+ PYTHON_PLATFORM_CONFIG-$(sdk) =$$(PYTHON_INSTALL-$(sdk ) ) /platform-config
427445
428446$$(PYTHON_LIB-$(sdk ) ) : $$(foreach target,$$(SDK_TARGETS-$(sdk ) ) ,$$(PYTHON_LIB-$$(target ) ) )
429447 @echo " >>> Build Python fat library for the $( sdk) SDK"
@@ -459,7 +477,7 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
459477 cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
460478
461479
462- $$(PYTHON_STDLIB-$(sdk ) ) /LICENSE.TXT : $$(PYTHON_LIB-$(sdk ) ) $$(PYTHON_FRAMEWORK-$(sdk ) ) /Info.plist $$(PYTHON_INCLUDE-$(sdk ) ) /pyconfig.h
480+ $$(PYTHON_STDLIB-$(sdk ) ) /LICENSE.TXT : $$(PYTHON_LIB-$(sdk ) ) $$(PYTHON_FRAMEWORK-$(sdk ) ) /Info.plist $$(PYTHON_INCLUDE-$(sdk ) ) /pyconfig.h $$( foreach target, $$( SDK_TARGETS- $( sdk ) ) , $$( PYTHON_PLATFORM_SITECUSTOMIZE- $$( target ) ) )
463481 @echo " >>> Build Python stdlib for the $( sdk) SDK"
464482 mkdir -p $$(PYTHON_STDLIB-$(sdk ) ) /lib-dynload
465483 # Copy stdlib from the first target associated with the $(sdk) SDK
@@ -468,11 +486,17 @@ $$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-
468486 # Delete the single-SDK parts of the standard library
469487 rm -rf \
470488 $$(PYTHON_STDLIB-$(sdk))/_sysconfigdata__*.py \
489+ $$(PYTHON_STDLIB-$(sdk))/_sysconfig_vars__*.json \
471490 $$(PYTHON_STDLIB-$(sdk))/config-* \
472491 $$(PYTHON_STDLIB-$(sdk))/lib-dynload/*
473492
474493 # Copy the individual _sysconfigdata modules into names that include the architecture
475494 $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_STDLIB-$$(target))/_sysconfigdata_* $$(PYTHON_STDLIB-$(sdk))/; )
495+ $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_STDLIB-$$(target))/_sysconfig_vars_* $$(PYTHON_STDLIB-$(sdk))/; )
496+
497+ # Copy the platform site folders for each architecture
498+ mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(sdk))
499+ $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp -r $$(PYTHON_PLATFORM_CONFIG-$$(target)) $$(PYTHON_PLATFORM_CONFIG-$(sdk)); )
476500
477501 # Merge the binary modules from each target in the $(sdk) SDK into a single binary
478502 $$(foreach module,$$(wildcard $$(PYTHON_STDLIB-$$(firstword $$(SDK_TARGETS-$(sdk))))/lib-dynload/*),lipo -create -output $$(PYTHON_STDLIB-$(sdk))/lib-dynload/$$(notdir $$(module)) $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_STDLIB-$$(target))/lib-dynload/$$(notdir $$(module))); )
@@ -581,7 +605,7 @@ support/$(PYTHON_VER)/macOS/VERSIONS:
581605dist/Python-$(PYTHON_VER ) -macOS-support.$(BUILD_NUMBER ) .tar.gz : \
582606 $$(PYTHON_XCFRAMEWORK-macOS ) /Info.plist \
583607 support/$(PYTHON_VER ) /macOS/VERSIONS \
584- $$(foreach target,$$(TARGETS-macOS ) , $$(PYTHON_SITECUSTOMIZE -$$(target ) ) )
608+ $$(foreach target,$$(TARGETS-macOS ) , $$(PYTHON_PLATFORM_SITECUSTOMIZE -$$(target ) ) )
585609
586610 @echo ">>> Create final distribution artefact for macOS"
587611 mkdir -p dist
@@ -604,9 +628,7 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
604628 $$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/include $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
605629 $$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/bin $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
606630 $$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/lib $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
607-
608- @echo ">>> Create helper links in XCframework for $(os)"
609- $$(foreach sdk,$$(SDKS-$(os)),ln -si $$(SDK_SLICE-$$(sdk)) $$(PYTHON_XCFRAMEWORK-$(os))/$$(sdk); )
631+ $$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/platform-config $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
610632
611633ifeq ($(os ) ,iOS)
612634 @echo ">>> Clone testbed project for $(os)"
@@ -626,7 +648,7 @@ endif
626648
627649dist/Python-$(PYTHON_VER ) -$(os ) -support.$(BUILD_NUMBER ) .tar.gz : \
628650 $$(PYTHON_XCFRAMEWORK-$(os ) ) /Info.plist \
629- $$(foreach target,$$(TARGETS-$(os ) ) , $$(PYTHON_SITECUSTOMIZE -$$(target ) ) )
651+ $$(foreach target,$$(TARGETS-$(os ) ) , $$(PYTHON_PLATFORM_SITECUSTOMIZE -$$(target ) ) )
630652
631653 @echo ">>> Create final distribution artefact for $(os)"
632654 mkdir -p dist
0 commit comments