mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 00:05:59 +08:00
macOS: generate .pyenvrc during setup (#29698)
* Create .pyenvrc if it does not exist * Replace source zshrc with pyenvrc * Remove unnecessary variables if pyenv wasn't installed * Add check fo PYENV_SHELL * source instead of eval * printf instead of echo * leave previous pyenvrc path to source * Add newline * Change shebang * Dont source the file after setup * eval virtualenv-init too * modify comment * Just unset broken function on macos
This commit is contained in:
@@ -13,20 +13,30 @@ fi
|
||||
if ! command -v "pyenv" > /dev/null 2>&1; then
|
||||
echo "pyenv install ..."
|
||||
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
|
||||
PYENV_PATH_SETUP="export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH"
|
||||
fi
|
||||
|
||||
if [ -z "$PYENV_SHELL" ] || [ -n "$PYENV_PATH_SETUP" ]; then
|
||||
echo "pyenvrc setup ..."
|
||||
cat <<EOF > "${HOME}/.pyenvrc"
|
||||
if [ -z "\$PYENV_ROOT" ]; then
|
||||
export PATH=\$HOME/.pyenv/bin:\$HOME/.pyenv/shims:\$PATH
|
||||
$PYENV_PATH_SETUP
|
||||
export PYENV_ROOT="\$HOME/.pyenv"
|
||||
eval "\$(pyenv init --path)"
|
||||
eval "\$(pyenv init -)"
|
||||
eval "\$(pyenv virtualenv-init -)"
|
||||
fi
|
||||
EOF
|
||||
echo -e "\nsource ~/.pyenvrc" >> $RC_FILE
|
||||
|
||||
# activate pyenv now
|
||||
source $RC_FILE
|
||||
SOURCE_PYENVRC="source ~/.pyenvrc"
|
||||
if ! grep "^$SOURCE_PYENVRC$" $RC_FILE > /dev/null; then
|
||||
printf "\n$SOURCE_PYENVRC\n" >> $RC_FILE
|
||||
fi
|
||||
|
||||
eval "$SOURCE_PYENVRC"
|
||||
# $(pyenv init -) produces a function which is broken on bash 3.2 which ships on macOS
|
||||
if [ $(uname) == "Darwin" ]; then
|
||||
unset -f pyenv
|
||||
fi
|
||||
fi
|
||||
|
||||
export MAKEFLAGS="-j$(nproc)"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user