diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 68d44b9ed..2ddefe48c 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -22,6 +22,7 @@ BuildSelector, NonPlatformWheelError, call, + detect_ci_provider, download, get_build_verbosity_extra_flags, get_pip_version, @@ -86,6 +87,17 @@ def install_cpython(version: str, url: str) -> Path: installation_path = Path(f"/Library/Frameworks/Python.framework/Versions/{version}") if python_package_identifier not in installed_system_packages: + if detect_ci_provider() is None: + # if running locally, we don't want to install CPython with sudo + # let the user know & provide a link to the installer + print( + f"Error: CPython {version} is not installed.\n" + "cibuildwheel will not perform system-wide installs when running outside of CI.\n" + f"To build locally, install CPython {version} on this machine, or, disable this version of Python using CIBW_SKIP=cp{version.replace('.', '')}-macosx_*\n" + f"\nDownload link: {url}", + file=sys.stderr, + ) + raise SystemExit(1) # download the pkg download(url, Path("/tmp/Python.pkg")) # install