1414
1515import asyncio
1616import io
17- import os
18- import stat
1917import subprocess
2018import sys
2119from pathlib import Path
2725from playwright .connection import Connection
2826from playwright .helper import Error
2927from playwright .object_factory import create_remote_object
30- from playwright .path_utils import get_file_dirname
28+ from playwright .path_utils import get_file_dirname , make_file_executable
3129from playwright .playwright import Playwright
3230from playwright .sync_api import Playwright as SyncPlaywright
3331from playwright .sync_base import dispatcher_fiber , set_dispatcher_fiber
@@ -37,15 +35,19 @@ def compute_driver_executable() -> Path:
3735 package_path = get_file_dirname ()
3836 platform = sys .platform
3937 if platform == "darwin" :
40- return package_path / "drivers" / "driver-darwin"
38+ path = package_path / "drivers" / "driver-darwin"
39+ return make_file_executable (path )
4140 elif platform == "linux" :
42- return package_path / "drivers" / "driver-linux"
41+ path = package_path / "drivers" / "driver-linux"
42+ return make_file_executable (path )
4343 elif platform == "win32" :
4444 result = package_path / "drivers" / "driver-win32-amd64.exe"
4545 if result .exists ():
4646 return result
4747 return package_path / "drivers" / "driver-win32.exe"
48- return package_path / "drivers" / "driver-linux"
48+
49+ path = package_path / "drivers" / "driver-linux"
50+ return make_file_executable (path )
4951
5052
5153async def run_driver_async () -> Connection :
@@ -140,11 +142,7 @@ def main() -> None:
140142 print ('Run "python -m playwright install" to complete installation' )
141143 return
142144 driver_executable = compute_driver_executable ()
143- # Fix the executable bit during the installation.
144- if not sys .platform == "win32" :
145- st = os .stat (driver_executable )
146- if st .st_mode & stat .S_IEXEC == 0 :
147- os .chmod (driver_executable , st .st_mode | stat .S_IEXEC )
145+
148146 print ("Installing the browsers..." )
149147 subprocess .check_call ([str (driver_executable ), "install" ])
150148
0 commit comments