Python 3.10.13 does not work after uninstalling Homebrew
Description
For my use-case I need to uninstall homebrew in order to prevent dependencies on homebrew-specific versions of libraries.
After doing this, I noticed that python 3.10 fails to start with the following error:
dyld[38390]: Library not loaded: '/usr/local/opt/gettext/lib/libintl.8.dylib'
Referenced from: '/Users/runner/hostedtoolcache/Python/3.10.13/x64/bin/python3.10'
Reason: tried: '/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/usr/local/lib/libintl.8.dylib' (no such file), '/usr/lib/libintl.8.dylib' (no such file)
/Users/runner/work/_temp/836966da-e0a6-4217-8a71-636a88c30284.sh: line 1: 38390 Abort trap: 6 python3.10 -m pip install -r requirements.txt
Probably that version of CPython was built with Homebrew present which contaminated it.
Platforms affected
- [X] Azure DevOps
- [ ] GitHub Actions - Standard Runners
- [ ] GitHub Actions - Larger Runners
Runner images affected
- [ ] Ubuntu 20.04
- [ ] Ubuntu 22.04
- [X] macOS 11
- [X] macOS 12
- [X] macOS 13
- [ ] Windows Server 2019
- [ ] Windows Server 2022
Image version and build link
macOS 12 20231216.1
https://dev.azure.com/Nuitka/Nuitka-Watch/_build/results?buildId=38&view=logs&j=7f33e5bd-7764-5d8a-ba2e-506e078b9c3f&t=5f980cba-253f-56da-0cba-c1322a20cb47
Is it regression?
Unknown. Python 3.11 works.
Expected behavior
Python should not depend on Homebrew.
Actual behavior
Python 3.10 fails to start when Homebrew is removed.
Repro steps
- Uninstall homebrew.
- UsePythonVersion 3.10
- Run python3.10
transferring to setup-python, but from what is seen, you can not uninstall brew, python3.10 is built against some dynamic shared libraries which are installed in the runner using homebrew, if you are uninstalling home-brew it leaves the deportee situation entirely to you and you should manually provide all the searchpaths
The proper solution should be to not build against Homebrew since that would mean that any artifacts generated that contain the python library are now tied to Homebrew. The official CPython builds do not have such a dependency and keeping as close as possible to official builds should be preferred.
This also affects standard runner on macos-14:
Operating System
macOS
14.4.1
2[3](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:1:3)E224
Runner Image
Image: macos-1[4](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:1:4)-arm64
Version: 20240422.3
Included Software: https://github.com/actions/runner-images/blob/macos-14-arm[6](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:1:7)4/20240422.3/images/macos/macos-14-arm64-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240422.3
gives:
Run actions/setup-python@v5
with:
python-version: 3.9
architecture: x64
check-latest: false
token: ***
update-environment: true
allow-prereleases: false
Installed versions
Version 3.9 was not found in the local cache
Version 3.9 is available for downloading
Download from "https://github.com/actions/python-versions/releases/download/3.9.19-836[2](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:2)510609/python-[3](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:3).9.19-darwin-x64.tar.gz"
Extract downloaded archive
/usr/bin/tar xz -C /Users/runner/work/_temp/cc[4](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:4)52abd-8085-42c3-ba81-649832[5](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:5)38058 -f /Users/runner/work/_temp/21[6](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:6)895ef-9e05-4cae-a864-1e5a08da3[7](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:7)6d
Execute installation script
Check if Python hostedtoolcache folder exist...
Create Python 3.9.19 folder
Copy Python binaries to hostedtoolcache folder
Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)
Upgrading pip...
Error: dyld[3[8](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:8)92]: Library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib
Referenced from: <64474517-EFC0-32F5-[9](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:10)3D6-1C4BAE8783F9> /Users/runner/hostedtoolcache/Python/3.9.19/x64/bin/python3.9
Reason: tried: '/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/usr/local/lib/libintl.8.dylib' (no such file), '/usr/lib/libintl.8.dylib' (no such file, not in dyld cache)
Error: ./setup.sh: line 52: 3892 Abort trap: 6 ./python -m ensurepip
Error: The process '/bin/bash' failed with exit code [13](https://github.com/jvesely/PsyNeuLink/actions/runs/8822788669/job/24221762710#step:6:14)4
Hello @Maxwell175,
Uninstalling Homebrew has resulted in the deletion of some related directories, including the one containing gettext, which is needed to install Python. The rebuilt Python package expects the gettext package at the previously provided path, but the package is located in the Cellar folder, which is the default behavior of Homebrew. This is the root cause. It might be a build process issue (incorrect set of options) or a Python core dependencies issue. The version of Python 3.10.13 that you are using was built with Homebrew present, resulting in a dependency on Homebrew-specific libraries such as libintl.8.dylib. When Homebrew is uninstalled and these libraries are no longer available, it causes Python to fail.
For Python >= 3.11, the builds are directly downloaded from python.org as universal2 binaries. These binaries are pre-built and do not have dependencies on Homebrew, thus avoiding the issue of missing Homebrew-specific libraries when Homebrew is uninstalled. This change in the build process for Python >= 3.11 ensures that these versions do not rely on Homebrew and are more portable across different macOS environments.