@@ -37,6 +37,15 @@ def extractall(zip: zipfile.ZipFile, path: str) -> None:
37
37
38
38
39
39
class PlaywrightBDistWheelCommand (BDistWheelCommand ):
40
+ user_options = BDistWheelCommand .user_options + [
41
+ ("all" , "a" , "create wheels for all platforms" )
42
+ ]
43
+ boolean_options = BDistWheelCommand .boolean_options + ["all" ]
44
+
45
+ def initialize_options (self ) -> None :
46
+ super ().initialize_options ()
47
+ self .all = False
48
+
40
49
def run (self ) -> None :
41
50
if os .path .exists ("build" ):
42
51
shutil .rmtree ("build" )
@@ -47,7 +56,16 @@ def run(self) -> None:
47
56
super ().run ()
48
57
os .makedirs ("driver" , exist_ok = True )
49
58
os .makedirs ("playwright/driver" , exist_ok = True )
50
- for platform in ["mac" , "linux" , "win32" , "win32_x64" ]:
59
+ platform_map = {
60
+ "darwin" : "mac" ,
61
+ "linux" : "linux" ,
62
+ "win32" : "win32_x64" if sys .maxsize > 2 ** 32 else "win32" ,
63
+ }
64
+ if self .all :
65
+ platforms = ["mac" , "linux" , "win32" , "win32_x64" ]
66
+ else :
67
+ platforms = [platform_map [sys .platform ]]
68
+ for platform in platforms :
51
69
zip_file = f"playwright-{ driver_version } -{ platform } .zip"
52
70
if not os .path .exists ("driver/" + zip_file ):
53
71
url = "https://playwright.azureedge.net/builds/driver/"
@@ -56,14 +74,10 @@ def run(self) -> None:
56
74
print ("Fetching " , url )
57
75
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
58
76
subprocess .check_call (["curl" , url , "-o" , "driver/" + zip_file ])
59
- base_wheel_location = glob .glob ("dist/ *.whl" )[0 ]
77
+ base_wheel_location = glob .glob (os . path . join ( self . dist_dir , " *.whl") )[0 ]
60
78
without_platform = base_wheel_location [:- 7 ]
61
- platform_map = {
62
- "darwin" : "mac" ,
63
- "linux" : "linux" ,
64
- "win32" : "win32_x64" if sys .maxsize > 2 ** 32 else "win32" ,
65
- }
66
- for platform in ["mac" , "linux" , "win32" , "win32_x64" ]:
79
+
80
+ for platform in platforms :
67
81
zip_file = f"driver/playwright-{ driver_version } -{ platform } .zip"
68
82
with zipfile .ZipFile (zip_file , "r" ) as zip :
69
83
extractall (zip , f"driver/{ platform } " )
@@ -88,26 +102,25 @@ def run(self) -> None:
88
102
from_path = os .path .join (dir_path , file )
89
103
to_path = os .path .relpath (from_path , driver_root )
90
104
zip .write (from_path , f"playwright/driver/{ to_path } " )
91
- if platform == "mac" :
105
+ if platform == "mac" and self . all :
92
106
# Ship mac both as 10_13 as and 11_0 universal to work across Macs.
93
107
universal_location = without_platform + "macosx_11_0_universal2.whl"
94
108
shutil .copyfile (wheel_location , universal_location )
95
109
with zipfile .ZipFile (universal_location , "a" ) as zip :
96
110
zip .writestr ("playwright/driver/README.md" , "Universal Mac package" )
97
111
98
112
os .remove (base_wheel_location )
99
- for whlfile in glob .glob ("dist/*.whl" ):
100
-
113
+ for whlfile in glob .glob (os .path .join (self .dist_dir , "*.whl" )):
101
114
os .makedirs ("wheelhouse" , exist_ok = True )
102
115
with InWheel (
103
116
in_wheel = whlfile ,
104
117
out_wheel = os .path .join ("wheelhouse" , os .path .basename (whlfile )),
105
118
ret_self = True ,
106
119
):
107
120
print ("Updating RECORD file of %s" % whlfile )
108
- shutil .rmtree ("dist" )
121
+ shutil .rmtree (self . dist_dir )
109
122
print ("Copying new wheels" )
110
- shutil .move ("wheelhouse" , "dist" )
123
+ shutil .move ("wheelhouse" , self . dist_dir )
111
124
112
125
113
126
setuptools .setup (
0 commit comments