14
14
15
15
import asyncio
16
16
import io
17
- import os
18
- import stat
19
17
import subprocess
20
18
import sys
21
19
from pathlib import Path
27
25
from playwright .connection import Connection
28
26
from playwright .helper import Error
29
27
from 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
31
29
from playwright .playwright import Playwright
32
30
from playwright .sync_api import Playwright as SyncPlaywright
33
31
from playwright .sync_base import dispatcher_fiber , set_dispatcher_fiber
@@ -37,15 +35,19 @@ def compute_driver_executable() -> Path:
37
35
package_path = get_file_dirname ()
38
36
platform = sys .platform
39
37
if platform == "darwin" :
40
- return package_path / "drivers" / "driver-darwin"
38
+ path = package_path / "drivers" / "driver-darwin"
39
+ return make_file_executable (path )
41
40
elif platform == "linux" :
42
- return package_path / "drivers" / "driver-linux"
41
+ path = package_path / "drivers" / "driver-linux"
42
+ return make_file_executable (path )
43
43
elif platform == "win32" :
44
44
result = package_path / "drivers" / "driver-win32-amd64.exe"
45
45
if result .exists ():
46
46
return result
47
47
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 )
49
51
50
52
51
53
async def run_driver_async () -> Connection :
@@ -140,11 +142,7 @@ def main() -> None:
140
142
print ('Run "python -m playwright install" to complete installation' )
141
143
return
142
144
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
+
148
146
print ("Installing the browsers..." )
149
147
subprocess .check_call ([str (driver_executable ), "install" ])
150
148
0 commit comments