summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/setuptools-rust/setuptools-rust-hook.sh
blob: 5a0916f8acc417614b1584df0a3e43d01a82ae6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# shellcheck shell=bash

echo "Sourcing setuptools-rust-hook"

setuptoolsRustSetup() {
    # This can work only if rustPlatform.cargoSetupHook is also included
    if ! command -v cargoSetupPostPatchHook >/dev/null; then
        echo "ERROR: setuptools-rust has to be used alongside with rustPlatform.cargoSetupHook!"
        exit 1
    fi

    export PYO3_CROSS_LIB_DIR="@pyLibDir@"
    export CARGO_BUILD_TARGET=@cargoBuildTarget@
    # TODO theoretically setting linker should not be required because it is
    # already set in pkgs/build-support/rust/hooks/default.nix but build fails
    # on missing linker without this.
    export CARGO_TARGET_@cargoLinkerVar@_LINKER=@targetLinker@
}

preConfigureHooks+=(setuptoolsRustSetup)