From 901e68f10e20b67c89dfe2087b895bace4bc6988 Mon Sep 17 00:00:00 2001 From: selimrecep Date: Sat, 3 Jan 2026 19:54:11 +0000 Subject: [PATCH] fix playwright upstream url and add assertion --- patch_python_package.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/patch_python_package.py b/patch_python_package.py index 5bceeb5..f459041 100644 --- a/patch_python_package.py +++ b/patch_python_package.py @@ -42,6 +42,9 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None: setup_source = f.read() setup_tree = ast.parse(setup_source) + # Check if driver URL is found in upstream Playwright + upstream_driver_url_found = False + for node in ast.walk(setup_tree): # Modify driver_version if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant) and isinstance(node.targets[0], ast.Name): @@ -50,7 +53,8 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None: # Modify url if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant) and isinstance(node.targets[0], ast.Name): - if node.targets[0].id == "url" and node.value.value == "https://playwright.azureedge.net/builds/driver/": + if node.targets[0].id == "url" and node.value.value == "https://cdn.playwright.dev/builds/driver/": + upstream_driver_url_found = True node.value = ast.JoinedStr( values=[ ast.Constant(value='https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/releases/download/v'), @@ -97,6 +101,9 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None: value=ast.Constant(value=patchright_version) )) + if not upstream_driver_url_found: + raise RuntimeError(f"Upstream Playwright CDN URL is not found in playwright-python/setup.py") + patch_file("playwright-python/setup.py", setup_tree) # Patching playwright/_impl/__pyinstaller/hook-playwright.async_api.py