Skip to content

Commit 4e16dd6

Browse files
Merge branch 'main' into remove-ghccc
2 parents 0f88955 + 7f6e884 commit 4e16dd6

File tree

139 files changed

+1696
-836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+1696
-836
lines changed

Android/android-env.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
: ${HOST:?} # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=21} # Minimum Android API level the build will run on
6+
: ${api_level:=24} # Minimum Android API level the build will run on
77
: ${PREFIX:-} # Path in which to find required libraries
88

99

@@ -24,7 +24,7 @@ fail() {
2424
# * https://android.googlesource.com/platform/ndk/+/ndk-rXX-release/docs/BuildSystemMaintainers.md
2525
# where XX is the NDK version. Do a diff against the version you're upgrading from, e.g.:
2626
# https://android.googlesource.com/platform/ndk/+/ndk-r25-release..ndk-r26-release/docs/BuildSystemMaintainers.md
27-
ndk_version=26.2.11394342
27+
ndk_version=27.1.12297006
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
3030
if ! [ -e $ndk ]; then
@@ -58,8 +58,8 @@ for path in "$AR" "$AS" "$CC" "$CXX" "$LD" "$NM" "$RANLIB" "$READELF" "$STRIP";
5858
fi
5959
done
6060

61-
export CFLAGS=""
62-
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment"
61+
export CFLAGS="-D__BIONIC_NO_PAGE_SIZE_MACRO"
62+
export LDFLAGS="-Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,-z,max-page-size=16384"
6363

6464
# Unlike Linux, Android does not implicitly use a dlopened library to resolve
6565
# relocations in subsequently-loaded libraries, even if RTLD_GLOBAL is used
@@ -85,6 +85,10 @@ if [ -n "${PREFIX:-}" ]; then
8585
export PKG_CONFIG_LIBDIR="$abs_prefix/lib/pkgconfig"
8686
fi
8787

88+
# When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
89+
# use CXXFLAGS alone.
90+
export CXXFLAGS=$CFLAGS
91+
8892
# Use the same variable name as conda-build
8993
if [ $(uname) = "Darwin" ]; then
9094
export CPU_COUNT=$(sysctl -n hw.ncpu)

Android/android.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def make_build_python(context):
138138

139139
def unpack_deps(host):
140140
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
141-
for name_ver in ["bzip2-1.0.8-1", "libffi-3.4.4-2", "openssl-3.0.15-0",
142-
"sqlite-3.45.1-0", "xz-5.4.6-0"]:
141+
for name_ver in ["bzip2-1.0.8-2", "libffi-3.4.4-3", "openssl-3.0.15-4",
142+
"sqlite-3.45.3-3", "xz-5.4.6-1"]:
143143
filename = f"{name_ver}-{host}.tar.gz"
144144
download(f"{deps_url}/{name_ver}/{filename}")
145145
run(["tar", "-xf", filename])
@@ -189,12 +189,13 @@ def configure_host_python(context):
189189

190190
def make_host_python(context):
191191
# The CFLAGS and LDFLAGS set in android-env include the prefix dir, so
192-
# delete any previously-installed Python libs and include files to prevent
193-
# them being used during the build.
192+
# delete any previous Python installation to prevent it being used during
193+
# the build.
194194
host_dir = subdir(context.host)
195195
prefix_dir = host_dir / "prefix"
196196
delete_glob(f"{prefix_dir}/include/python*")
197197
delete_glob(f"{prefix_dir}/lib/libpython*")
198+
delete_glob(f"{prefix_dir}/lib/python*")
198199

199200
os.chdir(host_dir / "build")
200201
run(["make", "-j", str(os.cpu_count())], host=context.host)

Android/testbed/app/build.gradle.kts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,47 @@ val PYTHON_VERSION = file("$PYTHON_DIR/Include/patchlevel.h").useLines {
3030
throw GradleException("Failed to find Python version")
3131
}
3232

33-
android.ndkVersion = file("../../android-env.sh").useLines {
34-
for (line in it) {
35-
val match = """ndk_version=(\S+)""".toRegex().find(line)
36-
if (match != null) {
37-
return@useLines match.groupValues[1]
38-
}
39-
}
40-
throw GradleException("Failed to find NDK version")
41-
}
42-
4333

4434
android {
35+
val androidEnvFile = file("../../android-env.sh").absoluteFile
36+
4537
namespace = "org.python.testbed"
4638
compileSdk = 34
4739

4840
defaultConfig {
4941
applicationId = "org.python.testbed"
50-
minSdk = 21
42+
43+
minSdk = androidEnvFile.useLines {
44+
for (line in it) {
45+
"""api_level:=(\d+)""".toRegex().find(line)?.let {
46+
return@useLines it.groupValues[1].toInt()
47+
}
48+
}
49+
throw GradleException("Failed to find API level in $androidEnvFile")
50+
}
5151
targetSdk = 34
52+
5253
versionCode = 1
5354
versionName = "1.0"
5455

5556
ndk.abiFilters.addAll(ABIS.keys)
5657
externalNativeBuild.cmake.arguments(
5758
"-DPYTHON_CROSS_DIR=$PYTHON_CROSS_DIR",
58-
"-DPYTHON_VERSION=$PYTHON_VERSION")
59+
"-DPYTHON_VERSION=$PYTHON_VERSION",
60+
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
61+
)
5962

6063
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
6164
}
6265

66+
ndkVersion = androidEnvFile.useLines {
67+
for (line in it) {
68+
"""ndk_version=(\S+)""".toRegex().find(line)?.let {
69+
return@useLines it.groupValues[1]
70+
}
71+
}
72+
throw GradleException("Failed to find NDK version in $androidEnvFile")
73+
}
6374
externalNativeBuild.cmake {
6475
path("src/main/c/CMakeLists.txt")
6576
}

Android/testbed/app/src/main/c/main_activity.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ typedef struct {
3434
int pipe[2];
3535
} StreamInfo;
3636

37+
// The FILE member can't be initialized here because stdout and stderr are not
38+
// compile-time constants. Instead, it's initialized immediately before the
39+
// redirection.
3740
static StreamInfo STREAMS[] = {
38-
{stdout, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
39-
{stderr, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
41+
{NULL, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
42+
{NULL, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
4043
{NULL, -1, ANDROID_LOG_UNKNOWN, NULL, {-1, -1}},
4144
};
4245

@@ -87,6 +90,8 @@ static char *redirect_stream(StreamInfo *si) {
8790
JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToLogcat(
8891
JNIEnv *env, jobject obj
8992
) {
93+
STREAMS[0].file = stdout;
94+
STREAMS[1].file = stderr;
9095
for (StreamInfo *si = STREAMS; si->file; si++) {
9196
char *error_prefix;
9297
if ((error_prefix = redirect_stream(si))) {

Android/testbed/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id("com.android.application") version "8.4.2" apply false
3+
id("com.android.application") version "8.6.1" apply false
44
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Mon Feb 19 20:29:06 GMT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

Doc/c-api/type.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,20 @@ The following functions and structs are used to create
413413
Creating classes whose metaclass overrides
414414
:c:member:`~PyTypeObject.tp_new` is no longer allowed.
415415
416+
.. c:function:: int PyType_Freeze(PyTypeObject *type)
417+
418+
Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag.
419+
420+
All base classes of *type* must be immutable.
421+
422+
On success, return ``0``.
423+
On error, set an exception and return ``-1``.
424+
425+
The type must not be used before it's made immutable. For example, type
426+
instances must not be created before the type is made immutable.
427+
428+
.. versionadded:: 3.14
429+
416430
.. raw:: html
417431
418432
<!-- Keep old URL fragments working (see gh-97908) -->

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ Pending removal in future versions
44
The following APIs will be removed in the future,
55
although there is currently no date scheduled for their removal.
66

7-
* :mod:`argparse`:
8-
9-
* Nesting argument groups and nesting mutually exclusive
10-
groups are deprecated.
11-
* Passing the undocumented keyword argument *prefix_chars* to
12-
:meth:`~argparse.ArgumentParser.add_argument_group` is now
13-
deprecated.
14-
15-
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
16-
177
* :mod:`builtins`:
188

199
* ``bool(NotImplemented)``.
@@ -43,6 +33,17 @@ although there is currently no date scheduled for their removal.
4333
as a single positional argument.
4434
(Contributed by Serhiy Storchaka in :gh:`109218`.)
4535

36+
* :mod:`argparse`:
37+
38+
* Nesting argument groups and nesting mutually exclusive
39+
groups are deprecated.
40+
* Passing the undocumented keyword argument *prefix_chars* to
41+
:meth:`~argparse.ArgumentParser.add_argument_group` is now
42+
deprecated.
43+
* The :class:`argparse.FileType` type converter is deprecated.
44+
45+
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
46+
4647
* :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are
4748
deprecated and replaced by :data:`calendar.JANUARY` and
4849
:data:`calendar.FEBRUARY`.

Doc/library/argparse.rst

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,21 @@ how the command-line arguments should be handled. The supplied actions are:
741741
>>> parser.parse_args('--str --int'.split())
742742
Namespace(types=[<class 'str'>, <class 'int'>])
743743

744+
* ``'extend'`` - This stores a list and appends each item from the multi-value
745+
argument list to it.
746+
The ``'extend'`` action is typically used with the nargs_ keyword argument
747+
value ``'+'`` or ``'*'``.
748+
Note that when nargs_ is ``None`` (the default) or ``'?'``, each
749+
character of the argument string will be appended to the list.
750+
Example usage::
751+
752+
>>> parser = argparse.ArgumentParser()
753+
>>> parser.add_argument("--foo", action="extend", nargs="+", type=str)
754+
>>> parser.parse_args(["--foo", "f1", "--foo", "f2", "f3", "f4"])
755+
Namespace(foo=['f1', 'f2', 'f3', 'f4'])
756+
757+
.. versionadded:: 3.8
758+
744759
* ``'count'`` - This counts the number of times a keyword argument occurs. For
745760
example, this is useful for increasing verbosity levels::
746761

@@ -766,17 +781,6 @@ how the command-line arguments should be handled. The supplied actions are:
766781
>>> parser.parse_args(['--version'])
767782
PROG 2.0
768783

769-
* ``'extend'`` - This stores a list, and extends each argument value to the
770-
list.
771-
Example usage::
772-
773-
>>> parser = argparse.ArgumentParser()
774-
>>> parser.add_argument("--foo", action="extend", nargs="+", type=str)
775-
>>> parser.parse_args(["--foo", "f1", "--foo", "f2", "f3", "f4"])
776-
Namespace(foo=['f1', 'f2', 'f3', 'f4'])
777-
778-
.. versionadded:: 3.8
779-
780784
Only actions that consume command-line arguments (e.g. ``'store'``,
781785
``'append'`` or ``'extend'``) can be used with positional arguments.
782786

@@ -865,16 +869,14 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are:
865869
output files::
866870

867871
>>> parser = argparse.ArgumentParser()
868-
>>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
869-
... default=sys.stdin)
870-
>>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
871-
... default=sys.stdout)
872+
>>> parser.add_argument('infile', nargs='?')
873+
>>> parser.add_argument('outfile', nargs='?')
872874
>>> parser.parse_args(['input.txt', 'output.txt'])
873-
Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,
874-
outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)
875+
Namespace(infile='input.txt', outfile='output.txt')
876+
>>> parser.parse_args(['input.txt'])
877+
Namespace(infile='input.txt', outfile=None)
875878
>>> parser.parse_args([])
876-
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
877-
outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
879+
Namespace(infile=None, outfile=None)
878880

879881
.. index:: single: * (asterisk); in argparse module
880882

@@ -1033,7 +1035,6 @@ Common built-in types and functions can be used as type converters:
10331035
parser.add_argument('distance', type=float)
10341036
parser.add_argument('street', type=ascii)
10351037
parser.add_argument('code_point', type=ord)
1036-
parser.add_argument('dest_file', type=argparse.FileType('w', encoding='latin-1'))
10371038
parser.add_argument('datapath', type=pathlib.Path)
10381039

10391040
User defined functions can be used as well:
@@ -1827,9 +1828,19 @@ FileType objects
18271828
>>> parser.parse_args(['-'])
18281829
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)
18291830

1831+
.. note::
1832+
1833+
If one argument uses *FileType* and then a subsequent argument fails,
1834+
an error is reported but the file is not automatically closed.
1835+
This can also clobber the output files.
1836+
In this case, it would be better to wait until after the parser has
1837+
run and then use the :keyword:`with`-statement to manage the files.
1838+
18301839
.. versionchanged:: 3.4
18311840
Added the *encodings* and *errors* parameters.
18321841

1842+
.. deprecated:: 3.14
1843+
18331844

18341845
Argument groups
18351846
^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)