diff --git a/chromedriver_autoinstaller/utils.py b/chromedriver_autoinstaller/utils.py index 805f1a4..bcf5f23 100644 --- a/chromedriver_autoinstaller/utils.py +++ b/chromedriver_autoinstaller/utils.py @@ -14,6 +14,7 @@ import xml.etree.ElementTree as elemTree import zipfile from io import BytesIO +import platform as pf __author__ = "Yeongbin Jo " @@ -40,13 +41,27 @@ def get_variable_separator(): return ":" -def get_platform_architecture(): +def get_platform_architecture(chrome_version=None): if sys.platform.startswith("linux") and sys.maxsize > 2**32: platform = "linux" architecture = "64" elif sys.platform == "darwin": platform = "mac" - architecture = "64" + if pf.processor() == "arm": + # At some point, the release naming for Apple arm changed; + # Looking in http://chromedriver.storage.googleapis.com/, the changeover happened across these releases: + # 106.0.5249.61/chromedriver_mac_arm64.zip + # 106.0.5249.21/chromedriver_mac64_m1.zip + if chrome_version is not None and chrome_version <= "106.0.5249.21": + print("CHROME <= 106.0.5249.21, using mac64_m1") + architecture = "64_m1" + else: + print("CHROME > 106.0.5249.21, using mac_arm64") + architecture = "_arm64" + elif pf.processor() == "i386": + architecture = "64" + else: + raise RuntimeError("Could not determine Mac processor architecture.") elif sys.platform.startswith("win"): platform = "win" architecture = "32" @@ -69,7 +84,7 @@ def get_chromedriver_url(version, no_ssl=False): base_url = "http://chromedriver.storage.googleapis.com/" else: base_url = "https://chromedriver.storage.googleapis.com/" - platform, architecture = get_platform_architecture() + platform, architecture = get_platform_architecture(version) return base_url + version + "/chromedriver_" + platform + architecture + ".zip"