def METHOD_NAME():
    dist = default_python_distribution(python_version="3.9")
    policy = dist.make_python_packaging_policy()
    policy.file_scanner_classify_files = True
    policy.include_classified_resources = False
    policy.allow_files = True
    policy.file_scanner_emit_files = True
    policy.include_file_resources = False
    policy.include_distribution_sources = False
    policy.include_distribution_resources = False
    policy.include_non_distribution_sources = False
    policy.include_test = False
    policy.resources_location = "in-memory"
    policy.resources_location_fallback = "filesystem-relative:lib"
    policy.register_resource_callback(handle_resource)
    policy.bytecode_optimize_level_zero = False
    policy.bytecode_optimize_level_two = True
    python_config = dist.make_python_interpreter_config()
    # detected libs do not need this, but we add extra afterwards
    python_config.module_search_paths = ["$ORIGIN/lib"]
    python_config.optimization_level = 2
    if BUILD_TARGET_TRIPLE == "x86_64-apple-darwin":
        # jemalloc currently fails to build when run under Rosetta
        python_config.allocator_backend = "default"
    python_config.run_command = "import aqt; aqt.run()"
    exe = dist.to_python_executable(
        name="anki",
        packaging_policy=policy,
        config=python_config,
    )
    exe.windows_runtime_dlls_mode = "always"
    # set in main.rs
    exe.windows_subsystem = "console"
    resources = exe.read_virtualenv(VARS.get("venv"))
    exe.add_python_resources(resources)
    return exe