1pytestXdistHook() { 2 pytestFlagsArray+=( 3 "--numprocesses=$NIX_BUILD_CORES" 4 "--forked" 5 ) 6 7 # Using --forked on darwin leads to crashes when fork safety is 8 # enabled. This often happens when urllib tries to request proxy 9 # settings on MacOS through `urllib.request.getproxies()` 10 # - https://github.com/python/cpython/issues/77906 11 if [[ "$OSTYPE" == "darwin"* ]]; then 12 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES 13 fi 14} 15 16# the flags should be added before pytestCheckHook runs so 17# until we have dependency mechanism in generic builder, we need to use this ugly hack. 18 19if [ -z "${dontUsePytestXdist-}" ] && [ -z "${dontUsePytestCheck-}" ]; then 20 if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then 21 preDistPhases+=" " 22 preDistPhases="${preDistPhases/ pytestCheckPhase / pytestXdistHook pytestCheckPhase }" 23 else 24 preDistPhases+=" pytestXdistHook" 25 fi 26fi