diff --git a/pkgs/development/python-modules/pytest-xdist/setup-hook.sh b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh index 5523a7f360f5f..61d0f64d1a4da 100644 --- a/pkgs/development/python-modules/pytest-xdist/setup-hook.sh +++ b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh @@ -3,6 +3,14 @@ pytestXdistHook() { "--numprocesses=$NIX_BUILD_CORES" "--forked" ) + + # Using --forked on darwin leads to crashes when fork safety is + # enabled. This often happens when urllib tries to request proxy + # settings on MacOS through `urllib.request.getproxies()` + # - https://github.com/python/cpython/issues/77906 + if [[ "$OSTYPE" == "darwin"* ]]; then + export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES + fi } # the flags should be added before pytestCheckHook runs so