File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 22
33import asyncio
44import argparse
5- import json
65import os
76import re
87import shlex
@@ -547,12 +546,17 @@ async def run_testbed(context):
547546
548547
549548def 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
You can’t perform that action at this time.
0 commit comments