Move requests back to a lazy import again
Some checks failed
ci-build / build-source-dist (push) Has been cancelled
ci-build / Build wxPython documentation (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.10) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.11) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.12) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.13) (push) Has been cancelled
ci-build / build-wheels (arm64, macos-14, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, macos-13, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, ubuntu-22.04, 3.9) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x64, windows-2022, 3.9) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.10) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.11) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.12) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.13) (push) Has been cancelled
ci-build / build-wheels (x86, windows-2022, 3.9) (push) Has been cancelled
ci-build / Publish Python distribution to PyPI (push) Has been cancelled
ci-build / Create GitHub Release and upload source (push) Has been cancelled
ci-build / Upload wheels to snapshot-builds on wxpython.org (push) Has been cancelled

This way, it isn't required unless actually needed.
This commit is contained in:
Scott Talbert
2025-04-11 19:55:58 -04:00
parent 6a67f5dc1c
commit 920a2bde76

View File

@@ -21,8 +21,6 @@ import os
import re import re
import shutil import shutil
import subprocess import subprocess
import requests
from requests.exceptions import HTTPError
import traceback import traceback
from io import BytesIO from io import BytesIO
import bz2 import bz2
@@ -569,15 +567,16 @@ def downloadTool(cmd, cmdname, envvar):
url = f"{toolsURL}/{os.path.basename(cmd)}.bz2" url = f"{toolsURL}/{os.path.basename(cmd)}.bz2"
try: try:
import requests
resp = requests.get(url) resp = requests.get(url)
resp.raise_for_status() resp.raise_for_status()
except HTTPError: except requests.exceptions.HTTPError:
# The files could be packed as a tarball # The files could be packed as a tarball
url = url.replace(".bz2", ".tar.bz2") url = url.replace(".bz2", ".tar.bz2")
try: try:
resp = requests.get(url) resp = requests.get(url)
resp.raise_for_status() resp.raise_for_status()
except HTTPError: except requests.exceptions.HTTPError:
errorMsg('Unable to download ' + url, cmdname, envvar) errorMsg('Unable to download ' + url, cmdname, envvar)
traceback.print_exc() traceback.print_exc()
sys.exit(1) sys.exit(1)
@@ -702,6 +701,7 @@ def getMSWebView2():
msg('Downloading microsoft.web.webview2 {}...'.format(MS_edge_version)) msg('Downloading microsoft.web.webview2 {}...'.format(MS_edge_version))
try: try:
import requests
resp = requests.get(MS_edge_url) resp = requests.get(MS_edge_url)
resp.raise_for_status() resp.raise_for_status()
msg('Connection successful...') msg('Connection successful...')