Skip to content

Commit 29b5a13

Browse files
chore: drop win32 drivers (microsoft#993)
1 parent 6bc5afc commit 29b5a13

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

setup.py

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,67 +51,72 @@ def initialize_options(self) -> None:
5151
self.all = False
5252

5353
def run(self) -> None:
54-
if os.path.exists("build"):
55-
shutil.rmtree("build")
56-
if os.path.exists("dist"):
57-
shutil.rmtree("dist")
58-
if os.path.exists("playwright.egg-info"):
59-
shutil.rmtree("playwright.egg-info")
54+
shutil.rmtree("build", ignore_errors=True)
55+
shutil.rmtree("dist", ignore_errors=True)
56+
shutil.rmtree("playwright.egg-info", ignore_errors=True)
6057
super().run()
6158
os.makedirs("driver", exist_ok=True)
6259
os.makedirs("playwright/driver", exist_ok=True)
63-
platform_map = {
64-
"darwin": "mac",
65-
"linux": "linux",
66-
"win32": "win32_x64" if sys.maxsize > 2 ** 32 else "win32",
67-
}
6860
if self.all:
69-
platforms = ["mac", "linux", "win32", "win32_x64"]
61+
# If building for all platforms
62+
platform_map = {
63+
"darwin": {
64+
"zip_name": "mac",
65+
"wheels": ["macosx_10_13_x86_64.whl", "macosx_11_0_universal2.whl"],
66+
},
67+
"linux": {"zip_name": "linux", "wheels": ["manylinux1_x86_64.whl"]},
68+
"win32": {
69+
"zip_name": "win32_x64",
70+
"wheels": ["win32.whl", "win_amd64.whl"],
71+
},
72+
}
73+
platforms = [*platform_map.values()]
7074
else:
75+
# If building for only current platform
76+
platform_map = {
77+
"darwin": {
78+
"zip_name": "mac",
79+
"wheels": ["macosx_10_13_x86_64.whl"],
80+
},
81+
"linux": {"zip_name": "linux", "wheels": ["manylinux1_x86_64.whl"]},
82+
"win32": {
83+
"zip_name": "win32_x64",
84+
"wheels": ["win_amd64.whl"],
85+
},
86+
}
7187
platforms = [platform_map[sys.platform]]
7288
for platform in platforms:
73-
zip_file = f"playwright-{driver_version}-{platform}.zip"
89+
zip_file = f"playwright-{driver_version}-{platform['zip_name']}.zip"
7490
if not os.path.exists("driver/" + zip_file):
7591
url = "https://playwright.azureedge.net/builds/driver/"
76-
url = url + "next/"
77-
url = url + zip_file
78-
print("Fetching ", url)
92+
url += "next/"
93+
url += zip_file
94+
print(f"Fetching {url}")
7995
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
8096
subprocess.check_call(["curl", url, "-o", "driver/" + zip_file])
8197
base_wheel_location = glob.glob(os.path.join(self.dist_dir, "*.whl"))[0]
8298
without_platform = base_wheel_location[:-7]
8399

84100
for platform in platforms:
85-
zip_file = f"driver/playwright-{driver_version}-{platform}.zip"
101+
zip_file = f"driver/playwright-{driver_version}-{platform['zip_name']}.zip"
86102
with zipfile.ZipFile(zip_file, "r") as zip:
87-
extractall(zip, f"driver/{platform}")
88-
if platform_map[sys.platform] == platform:
103+
extractall(zip, f"driver/{platform['zip_name']}")
104+
if platform_map[sys.platform] in platforms:
89105
with zipfile.ZipFile(zip_file, "r") as zip:
90106
extractall(zip, "playwright/driver")
91-
wheel = ""
92-
if platform == "mac":
93-
wheel = "macosx_10_13_x86_64.whl"
94-
if platform == "linux":
95-
wheel = "manylinux1_x86_64.whl"
96-
if platform == "win32":
97-
wheel = "win32.whl"
98-
if platform == "win32_x64":
99-
wheel = "win_amd64.whl"
100-
wheel_location = without_platform + wheel
101-
shutil.copy(base_wheel_location, wheel_location)
102-
with zipfile.ZipFile(wheel_location, "a") as zip:
103-
driver_root = os.path.abspath(f"driver/{platform}")
104-
for dir_path, _, files in os.walk(driver_root):
105-
for file in files:
106-
from_path = os.path.join(dir_path, file)
107-
to_path = os.path.relpath(from_path, driver_root)
108-
zip.write(from_path, f"playwright/driver/{to_path}")
109-
if platform == "mac" and self.all:
110-
# Ship mac both as 10_13 as and 11_0 universal to work across Macs.
111-
universal_location = without_platform + "macosx_11_0_universal2.whl"
112-
shutil.copyfile(wheel_location, universal_location)
113-
with zipfile.ZipFile(universal_location, "a") as zip:
114-
zip.writestr("playwright/driver/README.md", "Universal Mac package")
107+
for wheel in platform["wheels"]:
108+
wheel_location = without_platform + wheel
109+
shutil.copy(base_wheel_location, wheel_location)
110+
with zipfile.ZipFile(wheel_location, "a") as zip:
111+
driver_root = os.path.abspath(f"driver/{platform['zip_name']}")
112+
for dir_path, _, files in os.walk(driver_root):
113+
for file in files:
114+
from_path = os.path.join(dir_path, file)
115+
to_path = os.path.relpath(from_path, driver_root)
116+
zip.write(from_path, f"playwright/driver/{to_path}")
117+
zip.writestr(
118+
"playwright/driver/README.md", f"{wheel} driver package"
119+
)
115120

116121
os.remove(base_wheel_location)
117122
if InWheel:
@@ -121,7 +126,7 @@ def run(self) -> None:
121126
in_wheel=whlfile,
122127
out_wheel=os.path.join("wheelhouse", os.path.basename(whlfile)),
123128
):
124-
print("Updating RECORD file of %s" % whlfile)
129+
print(f"Updating RECORD file of {whlfile}")
125130
shutil.rmtree(self.dist_dir)
126131
print("Copying new wheels")
127132
shutil.move("wheelhouse", self.dist_dir)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy