Skip to content

Commit 901e68f

Browse files
committed
fix playwright upstream url and add assertion
1 parent 9517b4e commit 901e68f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

patch_python_package.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None:
4242
setup_source = f.read()
4343
setup_tree = ast.parse(setup_source)
4444

45+
# Check if driver URL is found in upstream Playwright
46+
upstream_driver_url_found = False
47+
4548
for node in ast.walk(setup_tree):
4649
# Modify driver_version
4750
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:
5053

5154
# Modify url
5255
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant) and isinstance(node.targets[0], ast.Name):
53-
if node.targets[0].id == "url" and node.value.value == "https://playwright.azureedge.net/builds/driver/":
56+
if node.targets[0].id == "url" and node.value.value == "https://cdn.playwright.dev/builds/driver/":
57+
upstream_driver_url_found = True
5458
node.value = ast.JoinedStr(
5559
values=[
5660
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:
97101
value=ast.Constant(value=patchright_version)
98102
))
99103

104+
if not upstream_driver_url_found:
105+
raise RuntimeError(f"Upstream Playwright CDN URL is not found in playwright-python/setup.py")
106+
100107
patch_file("playwright-python/setup.py", setup_tree)
101108

102109
# Patching playwright/_impl/__pyinstaller/hook-playwright.async_api.py

0 commit comments

Comments
 (0)