|  | 
| 2 | 2 | 
 | 
| 3 | 3 | import asyncio | 
| 4 | 4 | import argparse | 
|  | 5 | +import json | 
| 5 | 6 | import os | 
| 6 | 7 | import platform | 
| 7 | 8 | import re | 
| @@ -184,10 +185,16 @@ def make_build_python(context): | 
| 184 | 185 |     run(["make", "-j", str(os.cpu_count())]) | 
| 185 | 186 | 
 | 
| 186 | 187 | 
 | 
|  | 188 | +# To create new builds of these dependencies, usually all that's necessary is to | 
|  | 189 | +# push a tag to the cpython-android-source-deps repository, and GitHub Actions | 
|  | 190 | +# will do the rest. | 
|  | 191 | +# | 
|  | 192 | +# If you're a member of the Python core team, and you'd like to be able to push | 
|  | 193 | +# these tags yourself, please contact Malcolm Smith or Russell Keith-Magee. | 
| 187 | 194 | def unpack_deps(host, prefix_dir): | 
| 188 | 195 |     os.chdir(prefix_dir) | 
| 189 | 196 |     deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download" | 
| 190 |  | -    for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.15-4", | 
|  | 197 | +    for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.18-0", | 
| 191 | 198 |                      "sqlite-3.50.4-0", "xz-5.4.6-1", "zstd-1.5.7-1"]: | 
| 192 | 199 |         filename = f"{name_ver}-{host}.tar.gz" | 
| 193 | 200 |         download(f"{deps_url}/{name_ver}/{filename}") | 
| @@ -546,27 +553,33 @@ async def gradle_task(context): | 
| 546 | 553 |         task_prefix = "connected" | 
| 547 | 554 |         env["ANDROID_SERIAL"] = context.connected | 
| 548 | 555 | 
 | 
| 549 |  | -    if context.command: | 
| 550 |  | -        mode = "-c" | 
| 551 |  | -        module = context.command | 
| 552 |  | -    else: | 
| 553 |  | -        mode = "-m" | 
| 554 |  | -        module = context.module or "test" | 
|  | 556 | +    if context.ci_mode: | 
|  | 557 | +        context.args[0:0] = [ | 
|  | 558 | +            # See _add_ci_python_opts in libregrtest/main.py. | 
|  | 559 | +            "-W", "error", "-bb", "-E", | 
|  | 560 | + | 
|  | 561 | +            # Randomization is disabled because order-dependent failures are | 
|  | 562 | +            # much less likely to pass on a rerun in single-process mode. | 
|  | 563 | +            "-m", "test", | 
|  | 564 | +            f"--{context.ci_mode}-ci", "--single-process", "--no-randomize" | 
|  | 565 | +        ] | 
|  | 566 | + | 
|  | 567 | +    if not any(arg in context.args for arg in ["-c", "-m"]): | 
|  | 568 | +        context.args[0:0] = ["-m", "test"] | 
| 555 | 569 | 
 | 
| 556 | 570 |     args = [ | 
| 557 | 571 |         gradlew, "--console", "plain", f"{task_prefix}DebugAndroidTest", | 
| 558 | 572 |     ] + [ | 
| 559 |  | -        # Build-time properties | 
| 560 |  | -        f"-Ppython.{name}={value}" | 
| 561 |  | -        for name, value in [ | 
| 562 |  | -            ("sitePackages", context.site_packages), ("cwd", context.cwd) | 
| 563 |  | -        ] if value | 
| 564 |  | -    ] + [ | 
| 565 |  | -        # Runtime properties | 
| 566 |  | -        f"-Pandroid.testInstrumentationRunnerArguments.python{name}={value}" | 
|  | 573 | +        f"-P{name}={value}" | 
| 567 | 574 |         for name, value in [ | 
| 568 |  | -            ("Mode", mode), ("Module", module), ("Args", join_command(context.args)) | 
| 569 |  | -        ] if value | 
|  | 575 | +            ("python.sitePackages", context.site_packages), | 
|  | 576 | +            ("python.cwd", context.cwd), | 
|  | 577 | +            ( | 
|  | 578 | +                "android.testInstrumentationRunnerArguments.pythonArgs", | 
|  | 579 | +                json.dumps(context.args), | 
|  | 580 | +            ), | 
|  | 581 | +        ] | 
|  | 582 | +        if value | 
| 570 | 583 |     ] | 
| 571 | 584 |     if context.verbose >= 2: | 
| 572 | 585 |         args.append("--info") | 
| @@ -734,15 +747,14 @@ def ci(context): | 
| 734 | 747 |     else: | 
| 735 | 748 |         with TemporaryDirectory(prefix=SCRIPT_NAME) as temp_dir: | 
| 736 | 749 |             print("::group::Tests") | 
|  | 750 | + | 
| 737 | 751 |             # Prove the package is self-contained by using it to run the tests. | 
| 738 | 752 |             shutil.unpack_archive(package_path, temp_dir) | 
| 739 |  | - | 
| 740 |  | -            # Randomization is disabled because order-dependent failures are | 
| 741 |  | -            # much less likely to pass on a rerun in single-process mode. | 
| 742 |  | -            launcher_args = ["--managed", "maxVersion", "-v"] | 
| 743 |  | -            test_args = ["--fast-ci", "--single-process", "--no-randomize"] | 
|  | 753 | +            launcher_args = [ | 
|  | 754 | +                "--managed", "maxVersion", "-v", f"--{context.ci_mode}-ci" | 
|  | 755 | +            ] | 
| 744 | 756 |             run( | 
| 745 |  | -                ["./android.py", "test", *launcher_args, "--", *test_args], | 
|  | 757 | +                ["./android.py", "test", *launcher_args], | 
| 746 | 758 |                 cwd=temp_dir | 
| 747 | 759 |             ) | 
| 748 | 760 |             print("::endgroup::") | 
| @@ -825,25 +837,28 @@ def add_parser(*args, **kwargs): | 
| 825 | 837 |     test.add_argument( | 
| 826 | 838 |         "--cwd", metavar="DIR", type=abspath, | 
| 827 | 839 |         help="Directory to copy as the app's working directory.") | 
| 828 |  | - | 
| 829 |  | -    mode_group = test.add_mutually_exclusive_group() | 
| 830 |  | -    mode_group.add_argument( | 
| 831 |  | -        "-c", dest="command", help="Execute the given Python code.") | 
| 832 |  | -    mode_group.add_argument( | 
| 833 |  | -        "-m", dest="module", help="Execute the module with the given name.") | 
| 834 |  | -    test.epilog = ( | 
| 835 |  | -        "If neither -c nor -m are passed, the default is '-m test', which will " | 
| 836 |  | -        "run Python's own test suite.") | 
| 837 | 840 |     test.add_argument( | 
| 838 |  | -        "args", nargs="*", help=f"Arguments to add to sys.argv. " | 
| 839 |  | -        f"Separate them from {SCRIPT_NAME}'s own arguments with `--`.") | 
|  | 841 | +        "args", nargs="*", help=f"Python command-line arguments. " | 
|  | 842 | +        f"Separate them from {SCRIPT_NAME}'s own arguments with `--`. " | 
|  | 843 | +        f"If neither -c nor -m are included, `-m test` will be prepended, " | 
|  | 844 | +        f"which will run Python's own test suite.") | 
| 840 | 845 | 
 | 
| 841 | 846 |     # Package arguments. | 
| 842 | 847 |     for subcommand in [package, ci]: | 
| 843 | 848 |         subcommand.add_argument( | 
| 844 | 849 |             "-g", action="store_true", default=False, dest="debug", | 
| 845 | 850 |             help="Include debug information in package") | 
| 846 | 851 | 
 | 
|  | 852 | +    # CI arguments | 
|  | 853 | +    for subcommand in [test, ci]: | 
|  | 854 | +        group = subcommand.add_mutually_exclusive_group(required=subcommand is ci) | 
|  | 855 | +        group.add_argument( | 
|  | 856 | +            "--fast-ci", action="store_const", dest="ci_mode", const="fast", | 
|  | 857 | +            help="Add test arguments for GitHub Actions") | 
|  | 858 | +        group.add_argument( | 
|  | 859 | +            "--slow-ci", action="store_const", dest="ci_mode", const="slow", | 
|  | 860 | +            help="Add test arguments for buildbots") | 
|  | 861 | + | 
| 847 | 862 |     return parser.parse_args() | 
| 848 | 863 | 
 | 
| 849 | 864 | 
 | 
|  | 
0 commit comments