From: Jacob Lifshay Date: Tue, 27 Jul 2021 22:16:45 +0000 (-0700) Subject: fix libre-soc-install.sh running outside of a venv X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6061bf44d2f6fb7f5849b0d6feb6a5e45f81e54;p=power-instruction-analyzer.git fix libre-soc-install.sh running outside of a venv --- diff --git a/libre-soc-install.sh b/libre-soc-install.sh index 24ccf47..28ab21d 100755 --- a/libre-soc-install.sh +++ b/libre-soc-install.sh @@ -7,12 +7,22 @@ function fail() exit 1 } +if [[ "$VIRTUAL_ENV" == "" ]]; then + user=( "--user" ) +else + user=() +fi cargo_version="$(cargo --version)" || fail "can't find cargo, install it from https://rustup.rs/" [[ "$cargo_version" =~ ^'cargo 1.'([0-9]+)'.'[0-9]+' ' ]] || fail "can't parse cargo's version string" (( "${BASH_REMATCH[1]}" >= 53 )) || fail 'your rust version is not recent enough, update your rust version using `rustup update`' -python3 -m pip install 'maturin>=0.11,<0.12' -scripts="$(python3 -m sysconfig | sed 's/^\tscripts = "\([^"]\+\)"$/\1/p; d')" +python3 -m pip install "${user[@]}" 'maturin>=0.11,<0.12' +if [[ "$VIRTUAL_ENV" == "" ]]; then + scripts="$(python3 -m sysconfig | sed 's@^\tuserbase = "\([^"]\+\)"$@\1/bin@p; d')" +else + scripts="$(python3 -m sysconfig | sed 's/^\tscripts = "\([^"]\+\)"$/\1/p; d')" +fi +echo "$scripts" [[ -d "$scripts" ]] || fail "can't find python's \`scripts\` directory" rm -f target/wheels/power_instruction_analyzer-*.whl "$scripts"/maturin build --compatibility linux --cargo-extra-args=--features=python-extension -i python3 --release --no-sdist -python3 -m pip install target/wheels/power_instruction_analyzer-*.whl \ No newline at end of file +python3 -m pip install --force "${user[@]}" target/wheels/power_instruction_analyzer-*.whl \ No newline at end of file