MCPcopy
hub / github.com/emscripten-core/emsdk / download_firefox

Function download_firefox

emsdk.py:1262–1419  ·  view source on GitHub ↗
(tool)

Source from the content-addressed store, hash-verified

1260
1261
1262def download_firefox(tool):
1263 debug_print(f'download_firefox({tool})')
1264
1265 # Use mozdownload to acquire Firefox versions.
1266 try:
1267 from mozdownload import FactoryScraper
1268 except ImportError:
1269 # If mozdownload is not available, invoke pip to install it.
1270 subprocess.check_call([sys.executable, "-m", "pip", "install", "mozdownload"])
1271 from mozdownload import FactoryScraper
1272
1273 if WINDOWS:
1274 extension = 'exe'
1275 elif MACOS:
1276 extension = 'dmg'
1277 else:
1278 # N.b. on Linux even when we ask .tar.xz, we might sometimes get .tar.bz2,
1279 # depending on what is available on Firefox servers for the particular
1280 # version. So prepare to handle both further down below.
1281 extension = 'tar.xz'
1282
1283 platform = None
1284 if LINUX and 'arm' in ARCH:
1285 platform = 'linux-arm64'
1286 if WINDOWS and 'arm' in ARCH:
1287 platform = 'win64-aarch64'
1288
1289 if tool.version == 'nightly':
1290 scraper = FactoryScraper('daily', extension=extension, locale='en-US', platform=platform)
1291 else:
1292 scraper = FactoryScraper('release', extension=extension, locale='en-US', platform=platform, version=tool.version)
1293
1294 if tool.version == 'nightly':
1295 firefox_version = os.path.basename(scraper.filename).split(".en-US")[0]
1296 else:
1297 firefox_version = os.path.basename(scraper.filename).split("firefox-")[1].split(".en-US")[0]
1298
1299 print('Target Firefox version: ' + firefox_version)
1300 if tool.version in {'latest', 'latest-esr', 'latest-beta', 'nightly'}:
1301 pretend_version_dir = os.path.normpath(tool.installation_path())
1302 orig_version = tool.version
1303 tool.version = firefox_version
1304 root = os.path.normpath(tool.installation_path())
1305 tool.version = orig_version
1306 else:
1307 pretend_version_dir = None
1308 root = os.path.normpath(tool.installation_path())
1309
1310 # For moving installer packages, e.g. "nightly", "latest", "latest-esr",
1311 # store a text file to specify the actual installation directory.
1312 def save_actual_version():
1313 if os.path.isfile(firefox_exe) and pretend_version_dir:
1314 print(pretend_version_dir)
1315 os.makedirs(pretend_version_dir, exist_ok=True)
1316 open(os.path.join(pretend_version_dir, 'actual.txt'), 'w').write(os.path.relpath(root, EMSDK_PATH))
1317
1318 # Check if already installed
1319 print('Firefox installation root directory: ' + root)

Callers

nothing calls this directly

Calls 5

debug_printFunction · 0.85
exe_suffixFunction · 0.85
save_actual_versionFunction · 0.85
runFunction · 0.85
installation_pathMethod · 0.80

Tested by

no test coverage detected