Skip to content

chore: drop use win64 driver inside 32 bit windows package #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,58 +60,61 @@ def run(self) -> None:
super().run()
os.makedirs("driver", exist_ok=True)
os.makedirs("playwright/driver", exist_ok=True)
platform_map = {

platform_to_driver_map = {
"darwin": "mac",
"linux": "linux",
"win32": "win32_x64" if sys.maxsize > 2 ** 32 else "win32",
"win32": "win32_x64",
}
if self.all:
platforms = ["mac", "linux", "win32", "win32_x64"]
drivers = list(platform_to_driver_map.values())
else:
platforms = [platform_map[sys.platform]]
for platform in platforms:
zip_file = f"playwright-{driver_version}-{platform}.zip"
drivers = [platform_to_driver_map[sys.platform]]

# 1. Download necessary zip files
for driver in drivers:
zip_file = f"playwright-{driver_version}-{driver}.zip"
if not os.path.exists("driver/" + zip_file):
url = "https://playwright.azureedge.net/builds/driver/"
url = url + "next/"
url = url + zip_file
url = f"https://playwright.azureedge.net/builds/driver/next/{zip_file}"
print("Fetching ", url)
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
subprocess.check_call(["curl", url, "-o", "driver/" + zip_file])

# 2. Determine base wheel file
base_wheel_location = glob.glob(os.path.join(self.dist_dir, "*.whl"))[0]
without_platform = base_wheel_location[:-7]

for platform in platforms:
zip_file = f"driver/playwright-{driver_version}-{platform}.zip"
# 3. Build wheel/drivers combination list
driver_to_wheels_map = {
"mac": ["macosx_10_13_x86_64.whl", "macosx_11_0_universal2.whl"],
"linux": ["manylinux1_x86_64.whl"],
"win32_x64": ["win32.whl", "win_amd64.whl"],
}
wheels_driver_to_build = []
for driver in drivers:
for wheel in driver_to_wheels_map[driver]:
wheels_driver_to_build.append((driver, wheel))

# 4. Build the platform-specific wheels based on the base wheel file
for driver, wheel in wheels_driver_to_build:
zip_file = f"driver/playwright-{driver_version}-{driver}.zip"
with zipfile.ZipFile(zip_file, "r") as zip:
extractall(zip, f"driver/{platform}")
if platform_map[sys.platform] == platform:
extractall(zip, f"driver/{driver}")
# 4.1 For local development, we need to copy the driver to the playwright/driver directory.
if platform_to_driver_map[sys.platform] == driver:
with zipfile.ZipFile(zip_file, "r") as zip:
extractall(zip, "playwright/driver")
wheel = ""
if platform == "mac":
wheel = "macosx_10_13_x86_64.whl"
if platform == "linux":
wheel = "manylinux1_x86_64.whl"
if platform == "win32":
wheel = "win32.whl"
if platform == "win32_x64":
wheel = "win_amd64.whl"
wheel_location = without_platform + wheel
shutil.copy(base_wheel_location, wheel_location)
with zipfile.ZipFile(wheel_location, "a") as zip:
driver_root = os.path.abspath(f"driver/{platform}")
driver_root = os.path.abspath(f"driver/{driver}")
for dir_path, _, files in os.walk(driver_root):
for file in files:
from_path = os.path.join(dir_path, file)
to_path = os.path.relpath(from_path, driver_root)
zip.write(from_path, f"playwright/driver/{to_path}")
if platform == "mac" and self.all:
# Ship mac both as 10_13 as and 11_0 universal to work across Macs.
universal_location = without_platform + "macosx_11_0_universal2.whl"
shutil.copyfile(wheel_location, universal_location)
with zipfile.ZipFile(universal_location, "a") as zip:
zip.writestr("playwright/driver/README.md", "Universal Mac package")
# different PIP wheels can't be identical when getting uploaded
zip.writestr("playwright/driver/README", f"Wheel for {wheel}")

os.remove(base_wheel_location)
if InWheel:
Expand Down