Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked frompython/cpython

Commit8913836

Browse files
freakboy3742nineteendoncoghlanerlend-aasland
authored andcommitted
pythongh-120522: Add a--with-app-store-compliance configure option to patch out problematic code (python#120984)
* Add --app-store-compliance configuration option.* Added blurb.* Correct tab-vs-spaces formatting issue.* Correct source file name in docs.Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>* Correct source code reference in Mac docsCo-authored-by: Nice Zombies <nineteendo19d0@gmail.com>* Only apply the patch forward, and ensure the working directory is correct.* Make patching reslient to multiple builds.* Documentation fixes found during reviewCo-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>* Documentation and configure.ac syntax improvementsCo-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>* Regenerate configure script.* Silence the patch echo output.---------Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
1 parent7e1bf63 commit8913836

File tree

9 files changed

+238
-2
lines changed

9 files changed

+238
-2
lines changed

‎Doc/library/urllib.parse.rst‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ to an absolute URL given a "base URL."
2222

2323
The module has been designed to match the internet RFC on Relative Uniform
2424
Resource Locators. It supports the following URL schemes: ``file``, ``ftp``,
25-
``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``mailto``, ``mms``,
25+
``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``itms-services``, ``mailto``, ``mms``,
2626
``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtsps``, ``rtspu``,
2727
``sftp``, ``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``,
2828
``telnet``, ``wais``, ``ws``, ``wss``.
2929

30+
..impl-detail::
31+
32+
The inclusion of the ``itms-services`` URL scheme can prevent an app from
33+
passing Apple's App Store review process for the macOS and iOS App Stores.
34+
Handling for the ``itms-services`` scheme is always removed on iOS; on
35+
macOS, it *may* be removed if CPython has been built with the
36+
:option:`--with-app-store-compliance` option.
37+
3038
The:mod:`urllib.parse` module defines functions that fall into two broad
3139
categories: URL parsing and URL quoting. These are covered in detail in
3240
the following sections.

‎Doc/using/configure.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,17 @@ See :source:`Mac/README.rst`.
945945
Specify the name for the python framework on macOS only valid when
946946
:option:`--enable-framework` is set (default: ``Python``).
947947

948+
..option::--with-app-store-compliance
949+
..option::--with-app-store-compliance=PATCH-FILE
950+
951+
The Python standard library contains strings that are known to trigger
952+
automated inspection tool errors when submitted for distribution by
953+
the macOS and iOS App Stores. If enabled, this option will apply the list of
954+
patches that are known to correct app store compliance. A custom patch
955+
file can also be specified. This option is disabled by default.
956+
957+
..versionadded::3.13
958+
948959
iOS Options
949960
-----------
950961

‎Doc/using/ios.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,21 @@ modules in your app, some additional steps will be required:
312312

313313
* If you're using a separate folder for third-party packages, ensure that folder
314314
is included as part of the ``PYTHONPATH`` configuration in step 10.
315+
316+
App Store Compliance
317+
====================
318+
319+
The only mechanism for distributing apps to third-party iOS devices is to
320+
submit the app to the iOS App Store; apps submitted for distribution must pass
321+
Apple's app review process. This process includes a set of automated validation
322+
rules that inspect the submitted application bundle for problematic code.
323+
324+
The Python standard library contains some code that is known to violate these
325+
automated rules. While these violations appear to be false positives, Apple's
326+
review rules cannot be challenged; so, it is necessary to modify the Python
327+
standard library for an app to pass App Store review.
328+
329+
The Python source tree contains
330+
:source:`a patch file <Mac/Resources/app-store-compliance.patch>` that will remove
331+
all code that is known to cause issues with the App Store review process. This
332+
patch is applied automatically when building for iOS.

‎Doc/using/mac.rst‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,28 @@ distributable application:
188188
* `PyInstaller<https://pyinstaller.org/>`__: A cross-platform packaging tool that creates
189189
a single file or folder as a distributable artifact.
190190

191+
App Store Compliance
192+
--------------------
193+
194+
Apps submitted for distribution through the macOS App Store must pass Apple's
195+
app review process. This process includes a set of automated validation rules
196+
that inspect the submitted application bundle for problematic code.
197+
198+
The Python standard library contains some code that is known to violate these
199+
automated rules. While these violations appear to be false positives, Apple's
200+
review rules cannot be challenged. Therefore, it is necessary to modify the
201+
Python standard library for an app to pass App Store review.
202+
203+
The Python source tree contains
204+
:source:`a patch file <Mac/Resources/app-store-compliance.patch>` that will remove
205+
all code that is known to cause issues with the App Store review process. This
206+
patch is applied automatically when CPython is configured with the
207+
:option:`--with-app-store-compliance` option.
208+
209+
This patch is not normally required to use CPython on a Mac; nor is it required
210+
if you are distributing an app *outside* the macOS App Store. It is *only*
211+
required if you are using the macOS App Store as a distribution channel.
212+
191213
Other Resources
192214
===============
193215

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
2+
index d6c83a75c1c..19ed4e01091 100644
3+
--- a/Lib/test/test_urlparse.py
4+
+++ b/Lib/test/test_urlparse.py
5+
@@ -237,11 +237,6 @@ def test_roundtrips(self):
6+
'','',''),
7+
('git+ssh', 'git@github.com','/user/project.git',
8+
'', '')),
9+
- ('itms-services://?action=download-manifest&url=https://example.com/app',
10+
- ('itms-services', '', '', '',
11+
- 'action=download-manifest&url=https://example.com/app', ''),
12+
- ('itms-services', '', '',
13+
- 'action=download-manifest&url=https://example.com/app', '')),
14+
('+scheme:path/to/file',
15+
('', '', '+scheme:path/to/file', '', '', ''),
16+
('', '', '+scheme:path/to/file', '', '')),
17+
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
18+
index 8f724f907d4..148caf742c9 100644
19+
--- a/Lib/urllib/parse.py
20+
+++ b/Lib/urllib/parse.py
21+
@@ -59,7 +59,7 @@
22+
'imap', 'wais', 'file', 'mms', 'https', 'shttp',
23+
'snews', 'prospero', 'rtsp', 'rtsps', 'rtspu', 'rsync',
24+
'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh',
25+
- 'ws', 'wss', 'itms-services']
26+
+ 'ws', 'wss']
27+
28+
uses_params = ['', 'ftp', 'hdl', 'prospero', 'http', 'imap',
29+
'https', 'shttp', 'rtsp', 'rtsps', 'rtspu', 'sip',

‎Makefile.pre.in‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ EXPORTSFROM=@EXPORTSFROM@
178178
EXE=@EXEEXT@
179179
BUILDEXE=@BUILDEXEEXT@
180180

181+
# Name of the patch file to apply for app store compliance
182+
APP_STORE_COMPLIANCE_PATCH=@APP_STORE_COMPLIANCE_PATCH@
183+
181184
# Short name and location for Mac OS X Python framework
182185
UNIVERSALSDK=@UNIVERSALSDK@
183186
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
@@ -691,7 +694,7 @@ list-targets:
691694
@grep -E '^[A-Za-z][-A-Za-z0-9]+:' Makefile | awk -F : '{print $$1}'
692695

693696
.PHONY: build_all
694-
build_all:check-clean-src $(BUILDPYTHON) platform sharedmods \
697+
build_all:check-clean-src@APP_STORE_COMPLIANCE_PATCH_TARGET@$(BUILDPYTHON) platform sharedmods \
695698
gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
696699

697700
.PHONY: build_wasm
@@ -927,6 +930,18 @@ SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
927930
$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
928931
$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
929932

933+
# Compliance with app stores (such as iOS and macOS) sometimes requires making
934+
# modifications to the Python standard library. If enabled, apply the patch of
935+
# known modifications to the source tree before building. The patch will be
936+
# applied in a dry-run mode (validating, but not applying the patch) on builds
937+
# that *have* a compliance patch, but where compliance has not been enabled.
938+
build/app-store-compliant:
939+
patch @APP_STORE_COMPLIANCE_PATCH_FLAGS@ --forward --strip=1 --directory="$(srcdir)" --input "$(APP_STORE_COMPLIANCE_PATCH)"
940+
@if test "@APP_STORE_COMPLIANCE_PATCH_FLAGS@" == ""; then \
941+
mkdir -p build ; \
942+
echo "$(APP_STORE_COMPLIANCE_PATCH)" > build/app-store-compliant ; \
943+
fi
944+
930945
# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
931946
# minimal framework (not including the Lib directory and such) in the current
932947
# directory.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added a:option:`--with-app-store-compliance` option to patch out known issues
2+
with macOS/iOS App Store review processes.

‎configure‎

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,64 @@ AC_SUBST([INSTALLTARGETS])
695695
AC_DEFINE_UNQUOTED([_PYTHONFRAMEWORK],["${PYTHONFRAMEWORK}"],
696696
[framework name])
697697

698+
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
699+
AC_MSG_CHECKING([for --with-app-store-compliance])
700+
AC_ARG_WITH(
701+
[app_store_compliance],
702+
[AS_HELP_STRING(
703+
[--with-app-store-compliance=@<:@PATCH-FILE@:>@],
704+
[Enable any patches required for compiliance with app stores.
705+
Optional PATCH-FILE specifies the custom patch to apply.]
706+
)],[
707+
case "$withval" in
708+
yes)
709+
case $ac_sys_system in
710+
Darwin|iOS)
711+
# iOS is able to share the macOS patch
712+
APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch"
713+
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
714+
APP_STORE_COMPLIANCE_PATCH_FLAGS=
715+
;;
716+
*)AC_MSG_ERROR([no default app store compliance patch available for $ac_sys_system]) ;;
717+
esac
718+
AC_MSG_RESULT([applying default app store compliance patch])
719+
;;
720+
*)
721+
APP_STORE_COMPLIANCE_PATCH="${withval}"
722+
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
723+
APP_STORE_COMPLIANCE_PATCH_FLAGS=
724+
AC_MSG_RESULT([applying custom app store compliance patch])
725+
;;
726+
esac
727+
],[
728+
case $ac_sys_system in
729+
iOS)
730+
# Always apply the compliance patch on iOS; we can use the macOS patch
731+
APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch"
732+
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
733+
APP_STORE_COMPLIANCE_PATCH_FLAGS=
734+
AC_MSG_RESULT([applying default app store compliance patch])
735+
;;
736+
Darwin)
737+
# Always *check* the compliance patch on macOS
738+
APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch"
739+
APP_STORE_COMPLIANCE_PATCH_TARGET="build/app-store-compliant"
740+
APP_STORE_COMPLIANCE_PATCH_FLAGS="--dry-run"
741+
AC_MSG_RESULT([checking (not applying) default app store compliance patch])
742+
;;
743+
*)
744+
# No app compliance patching on any other platform
745+
APP_STORE_COMPLIANCE_PATCH=
746+
APP_STORE_COMPLIANCE_PATCH_TARGET=
747+
APP_STORE_COMPLIANCE_PATCH_FLAGS=
748+
AC_MSG_RESULT([not patching for app store compliance])
749+
;;
750+
esac
751+
])
752+
AC_SUBST([APP_STORE_COMPLIANCE_PATCH])
753+
AC_SUBST([APP_STORE_COMPLIANCE_PATCH_TARGET])
754+
AC_SUBST([APP_STORE_COMPLIANCE_PATCH_FLAGS])
755+
698756
AC_SUBST([_PYTHON_HOST_PLATFORM])
699757
if test "$cross_compiling" = yes; then
700758
case "$host" in

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp