1
+ diff --git a/Doc/using/ios.rst b/Doc/using/ios.rst
2
+ index dff694941d0..685d8e81add 100644
3
+ --- a/Doc/using/ios.rst
4
+ +++ b/Doc/using/ios.rst
5
+ @@ -296,9 +296,9 @@
6
+ * Buffered stdio (:c:member:`PyConfig.buffered_stdio`) is *disabled*;
7
+ * Writing bytecode (:c:member:`PyConfig.write_bytecode`) is *disabled*;
8
+ * Signal handlers (:c:member:`PyConfig.install_signal_handlers`) are *enabled*;
9
+ - * ``PYTHONHOME`` for the interpreter is configured to point at the
10
+ + * :envvar:`PYTHONHOME` for the interpreter is configured to point at the
11
+ ``python`` subfolder of your app's bundle; and
12
+ - * The ``PYTHONPATH`` for the interpreter includes:
13
+ + * The :envvar:`PYTHONPATH` for the interpreter includes:
14
+
15
+ - the ``python/lib/python3.X`` subfolder of your app's bundle,
16
+ - the ``python/lib/python3.X/lib-dynload`` subfolder of your app's bundle, and
17
+ @@ -322,7 +322,12 @@
18
+ the ``lib-dynload`` folder can be copied and adapted for this purpose.
19
+
20
+ * If you're using a separate folder for third-party packages, ensure that folder
21
+ - is included as part of the ``PYTHONPATH`` configuration in step 10.
22
+ + is included as part of the :envvar:`PYTHONPATH` configuration in step 10.
23
+ +
24
+ + * If any of the folders that contain third-party packages will contain ``.pth``
25
+ + files, you should add that folder as a *site directory* (using
26
+ + :meth:`site.addsitedir`), rather than adding to :envvar:`PYTHONPATH` or
27
+ + :attr:`sys.path` directly.
28
+
29
+ Testing a Python package
30
+ ------------------------
1
31
diff --git a/Lib/platform.py b/Lib/platform.py
2
32
index 8895177e326..eab586011ed 100755
3
33
--- a/Lib/platform.py
@@ -163,7 +193,7 @@ index f5cd73bdea8..50f2f8988b7 100644
163
193
# elif !defined(TARGET_OS_OSX) || TARGET_OS_OSX
164
194
PLATFORM_TRIPLET=darwin
165
195
diff --git a/configure b/configure
166
- index 1cd1f690f7b..34922ae651e 100755
196
+ index 519caa8ca74..5ae6de9bb44 100755
167
197
--- a/configure
168
198
+++ b/configure
169
199
@@ -979,6 +979,8 @@
@@ -563,7 +593,7 @@ index 1cd1f690f7b..34922ae651e 100755
563
593
fi
564
594
ac_fn_c_check_func "$LINENO" "fpathconf" "ac_cv_func_fpathconf"
565
595
if test "x$ac_cv_func_fpathconf" = xyes
566
- @@ -18486 ,24 +18617 ,6 @@
596
+ @@ -18492 ,24 +18623 ,6 @@
567
597
then :
568
598
printf "%s\n" "#define HAVE_POSIX_OPENPT 1" >>confdefs.h
569
599
@@ -588,7 +618,7 @@ index 1cd1f690f7b..34922ae651e 100755
588
618
fi
589
619
ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
590
620
if test "x$ac_cv_func_pread" = xyes
591
- @@ -18792 ,12 +18905 ,6 @@
621
+ @@ -18798 ,12 +18911 ,6 @@
592
622
then :
593
623
printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h
594
624
@@ -601,7 +631,7 @@ index 1cd1f690f7b..34922ae651e 100755
601
631
fi
602
632
ac_fn_c_check_func "$LINENO" "sigfillset" "ac_cv_func_sigfillset"
603
633
if test "x$ac_cv_func_sigfillset" = xyes
604
- @@ -19066 ,11 +19173 ,11 @@
634
+ @@ -19072 ,11 +19179 ,11 @@
605
635
606
636
fi
607
637
@@ -615,7 +645,7 @@ index 1cd1f690f7b..34922ae651e 100755
615
645
ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy"
616
646
if test "x$ac_cv_func_getentropy" = xyes
617
647
then :
618
- @@ -19092 ,6 +19199 ,53 @@
648
+ @@ -19098 ,6 +19205 ,53 @@
619
649
620
650
fi
621
651
@@ -669,7 +699,7 @@ index 1cd1f690f7b..34922ae651e 100755
669
699
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5
670
700
printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }
671
701
if test ${ac_cv_c_undeclared_builtin_options+y}
672
- @@ -21888 ,7 +22042 ,8 @@
702
+ @@ -21920 ,7 +22074 ,8 @@
673
703
674
704
675
705
# check for openpty, login_tty, and forkpty
@@ -679,7 +709,7 @@ index 1cd1f690f7b..34922ae651e 100755
679
709
680
710
for ac_func in openpty
681
711
do :
682
- @@ -21984 ,7 +22139 ,7 @@
712
+ @@ -22016 ,7 +22171 ,7 @@
683
713
fi
684
714
685
715
done
@@ -688,15 +718,15 @@ index 1cd1f690f7b..34922ae651e 100755
688
718
printf %s "checking for library containing login_tty... " >&6; }
689
719
if test ${ac_cv_search_login_tty+y}
690
720
then :
691
- @@ -22141 ,6 +22296 ,7 @@
721
+ @@ -22173 ,6 +22328 ,7 @@
692
722
fi
693
723
694
724
done
695
725
+ fi
696
726
697
727
# check for long file support functions
698
728
ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64"
699
- @@ -22387 ,10 +22543 ,10 @@
729
+ @@ -22419 ,10 +22575 ,10 @@
700
730
701
731
done
702
732
@@ -709,7 +739,7 @@ index 1cd1f690f7b..34922ae651e 100755
709
739
then
710
740
711
741
for ac_func in clock_settime
712
- @@ -24622 ,8 +24778 ,8 @@
742
+ @@ -24654 ,8 +24810 ,8 @@
713
743
LIBPYTHON="\$(BLDLIBRARY)"
714
744
fi
715
745
@@ -720,7 +750,7 @@ index 1cd1f690f7b..34922ae651e 100755
720
750
MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)"
721
751
fi
722
752
723
- @@ -27271 ,7 +27427 ,7 @@
753
+ @@ -27303 ,7 +27459 ,7 @@
724
754
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for device files" >&5
725
755
printf "%s\n" "$as_me: checking for device files" >&6;}
726
756
@@ -729,7 +759,7 @@ index 1cd1f690f7b..34922ae651e 100755
729
759
ac_cv_file__dev_ptmx=no
730
760
ac_cv_file__dev_ptc=no
731
761
else
732
- @@ -27704 ,7 +27860 ,7 @@
762
+ @@ -27736 ,7 +27892 ,7 @@
733
763
with_ensurepip=no ;; #(
734
764
WASI) :
735
765
with_ensurepip=no ;; #(
@@ -738,7 +768,7 @@ index 1cd1f690f7b..34922ae651e 100755
738
768
with_ensurepip=no ;; #(
739
769
*) :
740
770
with_ensurepip=upgrade
741
- @@ -28723 ,7 +28879 ,7 @@
771
+ @@ -28755 ,7 +28911 ,7 @@
742
772
;; #(
743
773
Darwin) :
744
774
;; #(
@@ -747,7 +777,7 @@ index 1cd1f690f7b..34922ae651e 100755
747
777
748
778
749
779
750
- @@ -32488 ,6 +32644 ,8 @@
780
+ @@ -32520 ,6 +32676 ,8 @@
751
781
"Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;;
752
782
"Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;;
753
783
"iOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES iOS/Resources/Info.plist" ;;
@@ -757,7 +787,7 @@ index 1cd1f690f7b..34922ae651e 100755
757
787
"Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;;
758
788
"Misc/python-embed.pc") CONFIG_FILES="$CONFIG_FILES Misc/python-embed.pc" ;;
759
789
diff --git a/configure.ac b/configure.ac
760
- index 3fcb18922c5..3a4167c96ee 100644
790
+ index 2a037569e49..39f84269378 100644
761
791
--- a/configure.ac
762
792
+++ b/configure.ac
763
793
@@ -330,6 +330,12 @@
@@ -1117,7 +1147,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1117
1147
- fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \
1118
1148
+ fpathconf fstatat ftime ftruncate futimens futimes futimesat \
1119
1149
gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \
1120
- getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin \
1150
+ getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin getlogin_r \
1121
1151
getpeername getpgid getpid getppid getpriority _getpty \
1122
1152
@@ -5122,15 +5253,14 @@
1123
1153
getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \
@@ -1161,8 +1191,8 @@ index 3fcb18922c5..3a4167c96ee 100644
1161
1191
fi
1162
1192
1163
1193
AC_CHECK_DECL([dirfd],
1164
- @@ -5401 ,20 +5539 ,22 @@
1165
- ])
1194
+ @@ -5413 ,20 +5551 ,22 @@
1195
+ [@%:@include <utmp.h> ])
1166
1196
1167
1197
# check for openpty, login_tty, and forkpty
1168
1198
-
@@ -1198,7 +1228,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1198
1228
1199
1229
# check for long file support functions
1200
1230
AC_CHECK_FUNCS([fseek64 fseeko fstatvfs ftell64 ftello statvfs])
1201
- @@ -5453 ,10 +5593 ,10 @@
1231
+ @@ -5465 ,10 +5605 ,10 @@
1202
1232
])
1203
1233
])
1204
1234
@@ -1211,7 +1241,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1211
1241
then
1212
1242
AC_CHECK_FUNCS([clock_settime], [], [
1213
1243
AC_CHECK_LIB([rt], [clock_settime], [
1214
- @@ -6205 ,8 +6345 ,8 @@
1244
+ @@ -6217 ,8 +6357 ,8 @@
1215
1245
LIBPYTHON="\$(BLDLIBRARY)"
1216
1246
fi
1217
1247
@@ -1222,7 +1252,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1222
1252
MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)"
1223
1253
fi
1224
1254
1225
- @@ -6814 ,7 +6954 ,7 @@
1255
+ @@ -6826 ,7 +6966 ,7 @@
1226
1256
dnl NOTE: Inform user how to proceed with files when cross compiling.
1227
1257
dnl Some cross-compile builds are predictable; they won't ever
1228
1258
dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly.
@@ -1231,7 +1261,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1231
1261
ac_cv_file__dev_ptmx=no
1232
1262
ac_cv_file__dev_ptc=no
1233
1263
else
1234
- @@ -7071 ,7 +7211 ,7 @@
1264
+ @@ -7083 ,7 +7223 ,7 @@
1235
1265
AS_CASE([$ac_sys_system],
1236
1266
[Emscripten], [with_ensurepip=no],
1237
1267
[WASI], [with_ensurepip=no],
@@ -1240,7 +1270,7 @@ index 3fcb18922c5..3a4167c96ee 100644
1240
1270
[with_ensurepip=upgrade]
1241
1271
)
1242
1272
])
1243
- @@ -7479 ,7 +7619 ,7 @@
1273
+ @@ -7491 ,7 +7631 ,7 @@
1244
1274
[VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [termios], [grp])],
1245
1275
dnl The _scproxy module is available on macOS
1246
1276
[Darwin], [],
@@ -1269,19 +1299,103 @@ index c3e261ecd9e..26ef7a95de4 100644
1269
1299
<key>CFBundleSupportedPlatforms</key>
1270
1300
<array>
1271
1301
<string>iPhoneOS</string>
1272
- diff --git a/iOS/testbed/__main__.py b/iOS/testbed/__main__.py
1273
- index c05497ede3a..1146bf3b988 100644
1274
- --- a/iOS/testbed/__main__.py
1275
- +++ b/iOS/testbed/__main__.py
1276
- @@ -127,7 +127,7 @@
1277
- async def select_simulator_device():
1278
- # List the testing simulators, in JSON format
1279
- raw_json = await async_check_output(
1280
- - "xcrun", "simctl", "--set", "testing", "list", "-j"
1281
- + "xcrun", "simctl", "list", "-j"
1282
- )
1283
- json_data = json.loads(raw_json)
1302
+ --- /dev/null
1303
+ +++ b/iOS/Resources/bin/arm64-apple-ios-simulator-strip
1304
+ @@ -0,0 +1,2 @@
1305
+ + #!/bin/sh
1306
+ + xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch arm64 "$@"
1307
+ --- /dev/null
1308
+ +++ b/iOS/Resources/bin/arm64-apple-ios-strip
1309
+ @@ -0,0 +1,2 @@
1310
+ + #!/bin/sh
1311
+ + xcrun --sdk iphoneos${IOS_SDK_VERSION} strip -arch arm64 "$@"
1312
+ --- /dev/null
1313
+ +++ b/iOS/Resources/bin/x86_64-apple-ios-simulator-strip
1314
+ @@ -0,0 +1,2 @@
1315
+ + #!/bin/sh
1316
+ + xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch x86_64 "$@"
1317
+ diff --git a/iOS/testbed/iOSTestbedTests/iOSTestbedTests.m b/iOS/testbed/iOSTestbedTests/iOSTestbedTests.m
1318
+ index d417b4cd63e..294a06f5305 100644
1319
+ --- a/iOS/testbed/iOSTestbedTests/iOSTestbedTests.m
1320
+ +++ b/iOS/testbed/iOSTestbedTests/iOSTestbedTests.m
1321
+ @@ -15,6 +15,11 @@
1322
+ PyStatus status;
1323
+ PyPreConfig preconfig;
1324
+ PyConfig config;
1325
+ + PyObject *app_packages_path;
1326
+ + PyObject *method_args;
1327
+ + PyObject *result;
1328
+ + PyObject *site_module;
1329
+ + PyObject *site_addsitedir_attr;
1330
+ PyObject *sys_module;
1331
+ PyObject *sys_path_attr;
1332
+ NSArray *test_args;
1333
+ @@ -109,29 +114,55 @@
1334
+ return;
1335
+ }
1336
+
1337
+ - sys_module = PyImport_ImportModule("sys");
1338
+ - if (sys_module == NULL) {
1339
+ - XCTFail(@"Could not import sys module");
1340
+ + // Add app_packages as a site directory. This both adds to sys.path,
1341
+ + // and ensures that any .pth files in that directory will be executed.
1342
+ + site_module = PyImport_ImportModule("site");
1343
+ + if (site_module == NULL) {
1344
+ + XCTFail(@"Could not import site module");
1345
+ return;
1346
+ }
1347
+
1348
+ - sys_path_attr = PyObject_GetAttrString(sys_module, "path");
1349
+ - if (sys_path_attr == NULL) {
1350
+ - XCTFail(@"Could not access sys.path");
1351
+ + site_addsitedir_attr = PyObject_GetAttrString(site_module, "addsitedir");
1352
+ + if (site_addsitedir_attr == NULL || !PyCallable_Check(site_addsitedir_attr)) {
1353
+ + XCTFail(@"Could not access site.addsitedir");
1354
+ return;
1355
+ }
1356
+
1357
+ - // Add the app packages path
1358
+ path = [NSString stringWithFormat:@"%@/app_packages", resourcePath, nil];
1359
+ NSLog(@"App packages path: %@", path);
1360
+ wtmp_str = Py_DecodeLocale([path UTF8String], NULL);
1361
+ - failed = PyList_Insert(sys_path_attr, 0, PyUnicode_FromString([path UTF8String]));
1362
+ - if (failed) {
1363
+ - XCTFail(@"Unable to add app packages to sys.path");
1364
+ + app_packages_path = PyUnicode_FromWideChar(wtmp_str, wcslen(wtmp_str));
1365
+ + if (app_packages_path == NULL) {
1366
+ + XCTFail(@"Could not convert app_packages path to unicode");
1367
+ return;
1368
+ }
1369
+ PyMem_RawFree(wtmp_str);
1284
1370
1371
+ + method_args = Py_BuildValue("(O)", app_packages_path);
1372
+ + if (method_args == NULL) {
1373
+ + XCTFail(@"Could not create arguments for site.addsitedir");
1374
+ + return;
1375
+ + }
1376
+ +
1377
+ + result = PyObject_CallObject(site_addsitedir_attr, method_args);
1378
+ + if (result == NULL) {
1379
+ + XCTFail(@"Could not add app_packages directory using site.addsitedir");
1380
+ + return;
1381
+ + }
1382
+ +
1383
+ + // Add test code to sys.path
1384
+ + sys_module = PyImport_ImportModule("sys");
1385
+ + if (sys_module == NULL) {
1386
+ + XCTFail(@"Could not import sys module");
1387
+ + return;
1388
+ + }
1389
+ +
1390
+ + sys_path_attr = PyObject_GetAttrString(sys_module, "path");
1391
+ + if (sys_path_attr == NULL) {
1392
+ + XCTFail(@"Could not access sys.path");
1393
+ + return;
1394
+ + }
1395
+ +
1396
+ path = [NSString stringWithFormat:@"%@/app", resourcePath, nil];
1397
+ NSLog(@"App path: %@", path);
1398
+ wtmp_str = Py_DecodeLocale([path UTF8String], NULL);
1285
1399
--- /dev/null
1286
1400
+++ b/tvOS/README.rst
1287
1401
@@ -0,0 +1,108 @@
0 commit comments