Skip to content

Commit 5832e30

Browse files
clementperonclaude
andcommitted
Address review comments
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYot8E3qW9g7WeV4rKmLZW
1 parent abfa4b2 commit 5832e30

3 files changed

Lines changed: 103 additions & 111 deletions

File tree

Platforms/Apple/iOS/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ A non-framework build is selected by omitting `--enable-framework`;
248248
`--disable-framework` is accepted as an explicit spelling of the same thing.
249249
Such a build is also static by default, as `--enable-shared` is off unless
250250
requested; `--enable-shared` without a framework is rejected, since an iOS app
251-
can only load a signed framework, never a bare dylib.
251+
can only load a signed framework, never a bare dylib. Neither option therefore
252+
needs to be given.
252253

253254
The minimal commands for a static build targeting ARM64 iOS devices are then:
254255
```
255256
export PATH="$(pwd)/Platforms/Apple/iOS/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
256257
./configure \
257-
--disable-framework \
258+
--prefix=/path/to/install/dir \
258259
--disable-test-modules \
259260
MODULE_BUILDTYPE=static \
260261
--host=arm64-apple-ios \
@@ -266,6 +267,8 @@ make install
266267
This produces a `libpython3.x.a` containing the interpreter and the standard
267268
library's extension modules; `make install` installs that archive, along with
268269
the standard library's Python source, into the location given by `--prefix`.
270+
Unlike a framework build, `--prefix` is not set for you, so specify it
271+
explicitly - otherwise `libpython` will be installed into `/usr/local`.
269272

270273
#### Limitations of a static build
271274

configure

Lines changed: 48 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -578,28 +578,25 @@ AC_ARG_ENABLE([framework],
578578
579579
case $enableval in
580580
no)
581-
case $ac_sys_system in
582-
*)
583-
PYTHONFRAMEWORK=
584-
PYTHONFRAMEWORKDIR=no-framework
585-
PYTHONFRAMEWORKPREFIX=
586-
PYTHONFRAMEWORKINSTALLDIR=
587-
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
588-
RESSRCDIR=
589-
FRAMEWORKINSTALLFIRST=
590-
FRAMEWORKINSTALLLAST=
591-
FRAMEWORKALTINSTALLFIRST=
592-
FRAMEWORKALTINSTALLLAST=
593-
FRAMEWORKPYTHONW=
594-
INSTALLTARGETS="commoninstall bininstall maninstall"
595-
596-
if test "x${prefix}" = "xNONE"; then
597-
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
598-
else
599-
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
600-
fi
601-
enable_framework=
602-
esac
581+
PYTHONFRAMEWORK=
582+
PYTHONFRAMEWORKDIR=no-framework
583+
PYTHONFRAMEWORKPREFIX=
584+
PYTHONFRAMEWORKINSTALLDIR=
585+
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
586+
RESSRCDIR=
587+
FRAMEWORKINSTALLFIRST=
588+
FRAMEWORKINSTALLLAST=
589+
FRAMEWORKALTINSTALLFIRST=
590+
FRAMEWORKALTINSTALLLAST=
591+
FRAMEWORKPYTHONW=
592+
INSTALLTARGETS="commoninstall bininstall maninstall"
593+
594+
if test "x${prefix}" = "xNONE"; then
595+
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
596+
else
597+
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
598+
fi
599+
enable_framework=
603600
;;
604601
*)
605602
PYTHONFRAMEWORKPREFIX="${enableval}"
@@ -687,27 +684,24 @@ AC_ARG_ENABLE([framework],
687684
esac
688685
esac
689686
],[
690-
case $ac_sys_system in
691-
*)
692-
PYTHONFRAMEWORK=
693-
PYTHONFRAMEWORKDIR=no-framework
694-
PYTHONFRAMEWORKPREFIX=
695-
PYTHONFRAMEWORKINSTALLDIR=
696-
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
697-
RESSRCDIR=
698-
FRAMEWORKINSTALLFIRST=
699-
FRAMEWORKINSTALLLAST=
700-
FRAMEWORKALTINSTALLFIRST=
701-
FRAMEWORKALTINSTALLLAST=
702-
FRAMEWORKPYTHONW=
703-
INSTALLTARGETS="commoninstall bininstall maninstall"
704-
if test "x${prefix}" = "xNONE" ; then
705-
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
706-
else
707-
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
708-
fi
709-
enable_framework=
710-
esac
687+
PYTHONFRAMEWORK=
688+
PYTHONFRAMEWORKDIR=no-framework
689+
PYTHONFRAMEWORKPREFIX=
690+
PYTHONFRAMEWORKINSTALLDIR=
691+
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
692+
RESSRCDIR=
693+
FRAMEWORKINSTALLFIRST=
694+
FRAMEWORKINSTALLLAST=
695+
FRAMEWORKALTINSTALLFIRST=
696+
FRAMEWORKALTINSTALLLAST=
697+
FRAMEWORKPYTHONW=
698+
INSTALLTARGETS="commoninstall bininstall maninstall"
699+
if test "x${prefix}" = "xNONE" ; then
700+
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
701+
else
702+
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
703+
fi
704+
enable_framework=
711705
])
712706
AC_SUBST([PYTHONFRAMEWORK])
713707
AC_SUBST([PYTHONFRAMEWORKIDENTIFIER])
@@ -1674,6 +1668,9 @@ if test $enable_shared = "yes"; then
16741668
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
16751669
;;
16761670
iOS)
1671+
if test -z "$PYTHONFRAMEWORK"; then
1672+
AC_MSG_ERROR([iOS shared builds must use --enable-framework; an iOS app can only load a signed framework, never a bare dylib])
1673+
fi
16771674
LDLIBRARY='libpython$(LDVERSION).dylib'
16781675
;;
16791676
AIX*)
@@ -1693,10 +1690,6 @@ else # shared is disabled
16931690
fi
16941691
AC_MSG_RESULT([$LDLIBRARY])
16951692

1696-
if test "$ac_sys_system" = "iOS" && test "$PY_ENABLE_SHARED" = 1 && test -z "$PYTHONFRAMEWORK"; then
1697-
AC_MSG_ERROR([iOS builds must use --enable-framework; --enable-shared cannot be used without a framework, as an iOS app can only load a signed framework])
1698-
fi
1699-
17001693
# HOSTRUNNER - Program to run CPython for the host platform
17011694
AC_MSG_CHECKING([HOSTRUNNER])
17021695
if test -z "$HOSTRUNNER"
@@ -8158,6 +8151,11 @@ AC_ARG_ENABLE([test-modules],
81588151
AS_VAR_IF([enable_test_modules], [yes], [TEST_MODULES=yes], [TEST_MODULES=no])
81598152
], [TEST_MODULES=yes])
81608153
AC_MSG_RESULT([$TEST_MODULES])
8154+
dnl Some test modules can only be built as shared libraries (see
8155+
dnl Modules/Setup.stdlib.in), which a non-framework iOS build cannot do.
8156+
AS_IF([test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK"],
8157+
[AS_IF([test "$TEST_MODULES" != "no"],
8158+
[AC_MSG_ERROR([iOS non-framework builds must use --disable-test-modules])])])
81618159
AC_SUBST([TEST_MODULES])
81628160

81638161
# Check for --with-build-details-suffix
@@ -8397,14 +8395,11 @@ AS_CASE([$host_cpu],
83978395
)
83988396
AC_SUBST([MODULE_BUILDTYPE])
83998397

8400-
dnl A non-framework iOS build can neither link nor load shared extension
8401-
dnl modules; some test modules can only be shared (see Modules/Setup.stdlib.in).
8402-
AS_IF([test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK"], [
8403-
AS_IF([test "$MODULE_BUILDTYPE" != "static"],
8404-
[AC_MSG_ERROR([iOS builds must use --enable-framework; a non-framework build cannot build shared extension modules, and requires MODULE_BUILDTYPE=static])])
8405-
AS_IF([test "$TEST_MODULES" != "no"],
8406-
[AC_MSG_ERROR([iOS builds must use --enable-framework; a non-framework build cannot build the shared test modules, and requires --disable-test-modules])])
8407-
])
8398+
dnl A non-framework iOS build has no framework for a shared extension module
8399+
dnl to link against, so every extension module must be built into libpython.
8400+
AS_IF([test "$ac_sys_system" = "iOS" && test -z "$PYTHONFRAMEWORK"],
8401+
[AS_IF([test "$MODULE_BUILDTYPE" != "static"],
8402+
[AC_MSG_ERROR([iOS non-framework builds must use MODULE_BUILDTYPE=static])])])
84088403

84098404
dnl _MODULE_BLOCK_ADD([VAR], [VALUE])
84108405
dnl internal: adds $1=quote($2) to MODULE_BLOCK

0 commit comments

Comments
 (0)