@@ -12,7 +12,6 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None:
1212
1313# Adding _repo_version.py (Might not be intended but fixes the build)
1414with open ("playwright-python/playwright/_repo_version.py" , "w" ) as f :
15- #f.write(f"version = {os.environ.get('playwright_version')}")
1615 f .write (f"version = '{ patchright_version } '" )
1716
1817# Patching pyproject.toml
@@ -101,6 +100,30 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None:
101100
102101 patch_file ("playwright-python/setup.py" , setup_tree )
103102
103+ # Patching playwright/_impl/__pyinstaller/hook-playwright.async_api.py
104+ with open ("playwright-python/playwright/_impl/__pyinstaller/hook-playwright.async_api.py" ) as f :
105+ async_api_source = f .read ()
106+ async_api_tree = ast .parse (async_api_source )
107+
108+ for node in ast .walk (async_api_tree ):
109+ if isinstance (node , ast .Call ) and isinstance (node .func , ast .Name ) and len (node .args ) == 1 and isinstance (node .args [0 ], ast .Constant ):
110+ if node .func .id == "collect_data_files" and node .args [0 ].value == "playwright" :
111+ node .args [0 ].value = "patchright"
112+
113+ patch_file ("playwright-python/playwright/_impl/__pyinstaller/hook-playwright.async_api.py" , async_api_tree )
114+
115+ # Patching playwright/_impl/__pyinstaller/hook-playwright.sync_api.py
116+ with open ("playwright-python/playwright/_impl/__pyinstaller/hook-playwright.sync_api.py" ) as f :
117+ async_api_source = f .read ()
118+ async_api_tree = ast .parse (async_api_source )
119+
120+ for node in ast .walk (async_api_tree ):
121+ if isinstance (node , ast .Call ) and isinstance (node .func , ast .Name ) and len (node .args ) == 1 and isinstance (node .args [0 ], ast .Constant ):
122+ if node .func .id == "collect_data_files" and node .args [0 ].value == "playwright" :
123+ node .args [0 ].value = "patchright"
124+
125+ patch_file ("playwright-python/playwright/_impl/__pyinstaller/hook-playwright.sync_api.py" , async_api_tree )
126+
104127# Patching playwright/_impl/_driver.py
105128with open ("playwright-python/playwright/_impl/_driver.py" ) as f :
106129 driver_source = f .read ()
0 commit comments