1515import glob
1616import os
1717import shutil
18- import stat
1918import subprocess
2019import sys
20+ import typing
2121import zipfile
2222
2323import setuptools
2424from wheel .bdist_wheel import bdist_wheel as BDistWheelCommand
2525
26- driver_version = "0.170 .0-next.1608058598043 "
26+ driver_version = "1.8 .0-next-1609895143000 "
2727
2828
2929with open ("README.md" , "r" , encoding = "utf-8" ) as fh :
3030 long_description = fh .read ()
3131
32+ NoneType = type (None )
33+
34+
35+ def extractall (zip : typing .Any , path : str ) -> NoneType :
36+ for name in zip .namelist ():
37+ member = zip .getinfo (name )
38+ extracted_path = zip ._extract_member (member , path , None )
39+ attr = member .external_attr >> 16
40+ if attr != 0 :
41+ os .chmod (extracted_path , attr )
42+
3243
3344class PlaywrightBDistWheelCommand (BDistWheelCommand ):
3445 def run (self ) -> None :
@@ -42,9 +53,12 @@ def run(self) -> None:
4253 os .makedirs ("driver" , exist_ok = True )
4354 os .makedirs ("playwright/driver" , exist_ok = True )
4455 for platform in ["mac" , "linux" , "win32" , "win32_x64" ]:
45- zip_file = f"playwright-cli- { driver_version } -{ platform } .zip"
56+ zip_file = f"playwright-{ driver_version } -{ platform } .zip"
4657 if not os .path .exists ("driver/" + zip_file ):
47- url = "https://playwright.azureedge.net/builds/cli/next/" + zip_file
58+ url = "https://playwright.azureedge.net/builds/driver/"
59+ if "-next" in driver_version :
60+ url = url + "next/"
61+ url = url + zip_file
4862 print ("Fetching " , url )
4963 subprocess .check_call (
5064 ["curl" , "--http1.1" , url , "-o" , "driver/" + zip_file ]
@@ -57,19 +71,12 @@ def run(self) -> None:
5771 "win32" : "win32_x64" if sys .maxsize > 2 ** 32 else "win32" ,
5872 }
5973 for platform in ["mac" , "linux" , "win32" , "win32_x64" ]:
60- zip_file = f"driver/playwright-cli- { driver_version } -{ platform } .zip"
74+ zip_file = f"driver/playwright-{ driver_version } -{ platform } .zip"
6175 with zipfile .ZipFile (zip_file , "r" ) as zip :
62- zip . extractall (f"driver/{ platform } " )
76+ extractall (zip , f"driver/{ platform } " )
6377 if platform_map [sys .platform ] == platform :
6478 with zipfile .ZipFile (zip_file , "r" ) as zip :
65- zip .extractall ("playwright/driver" )
66- for file in os .listdir ("playwright/driver" ):
67- if file == "playwright-cli" or file .startswith ("ffmpeg" ):
68- print (f"playwright/driver/{ file } " )
69- os .chmod (
70- f"playwright/driver/{ file } " ,
71- os .stat (f"playwright/driver/{ file } " ).st_mode | stat .S_IEXEC ,
72- )
79+ extractall (zip , "playwright/driver" )
7380 wheel = ""
7481 if platform == "mac" :
7582 wheel = "macosx_10_13_x86_64.whl"
@@ -82,14 +89,12 @@ def run(self) -> None:
8289 wheel_location = without_platform + wheel
8390 shutil .copy (base_wheel_location , wheel_location )
8491 with zipfile .ZipFile (wheel_location , "a" ) as zip :
85- for file in os .listdir (f"driver/{ platform } " ):
86- from_location = f"driver/{ platform } /{ file } "
87- to_location = f"playwright/driver/{ file } "
88- if file == "playwright-cli" or file .startswith ("ffmpeg" ):
89- os .chmod (
90- from_location , os .stat (from_location ).st_mode | stat .S_IEXEC
91- )
92- zip .write (from_location , to_location )
92+ driver_root = os .path .abspath (f"driver/{ platform } " )
93+ for dir_path , dirs , files in os .walk (driver_root ):
94+ for file in files :
95+ from_path = os .path .join (dir_path , file )
96+ to_path = os .path .relpath (from_path , driver_root )
97+ zip .write (from_path , f"playwright/driver/{ to_path } " )
9398 os .remove (base_wheel_location )
9499
95100
0 commit comments