summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pytest-forked/setup-hook.sh
blob: e613feadf8346e01205c410c3cb47f3350e603a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
pytestForkedHook() {
    pytestFlagsArray+=(
        "--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
# until we have dependency mechanism in generic builder, we need to use this ugly hack.

if [ -z "${dontUsePytestForked-}" ] && [ -z "${dontUsePytestCheck-}" ]; then
    if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then
        preDistPhases+=" "
        preDistPhases="${preDistPhases/ pytestCheckPhase / pytestForkedHook pytestCheckPhase }"
    else
        preDistPhases+=" pytestForkedHook"
    fi
fi