Skip to content

Commit 94a1b8e

Browse files
committed
Python 3.13 doesn't have the sysconfig json file, so use patchlevel.h instead
1 parent a467f0a commit 94a1b8e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Android/android.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import argparse
5-
import json
65
import os
76
import re
87
import shlex
@@ -547,12 +546,17 @@ async def run_testbed(context):
547546

548547

549548
def package_version(prefix_subdir):
550-
vars_glob = f"{prefix_subdir}/lib/python*/_sysconfig_vars__android_*.json"
551-
vars_paths = glob(vars_glob)
552-
if len(vars_paths) != 1:
553-
sys.exit(f"{vars_glob} matched {len(vars_paths)} paths.")
554-
with open(vars_paths[0]) as vars_file:
555-
version = json.load(vars_file)["py_version"]
549+
patchlevel_glob = f"{prefix_subdir}/include/python*/patchlevel.h"
550+
patchlevel_paths = glob(patchlevel_glob)
551+
if len(patchlevel_paths) != 1:
552+
sys.exit(f"{patchlevel_glob} matched {len(patchlevel_paths)} paths.")
553+
554+
for line in open(patchlevel_paths[0]):
555+
if match := re.fullmatch(r'\s*#define\s+PY_VERSION\s+"(.+)"\s*', line):
556+
version = match[1]
557+
break
558+
else:
559+
sys.exit(f"Failed to find Python version in {patchlevel_paths[0]}.")
556560

557561
# If not building against a tagged commit, add a timestamp to the version.
558562
# Follow the PyPA version number rules, as this will make it easier to

0 commit comments

Comments
 (0)