-
Notifications
You must be signed in to change notification settings - Fork 6
/
with_pyenv
executable file
·45 lines (38 loc) · 1.31 KB
/
with_pyenv
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash -x
# Run `with_pyenv pyenv update` or remove ./.pyenv or your $PYENV_ROOT to update environment
#
if [[ "${BASH_SOURCE[0]}" = bash ]] ; then
SCRIPT_DIR=$(dirname "$0")
else
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
fi
SCRIPT_DIR=$(realpath "$SCRIPT_DIR")
echo $SCRIPT_DIR
CCname=${CC:-${CXX:-default}}
export PYENV_VERSION=${PYENV_VERSION:-3.7.4}
export PYENV_ROOT="${PYENV_ROOT:-${SCRIPT_DIR}/.pyenv-${CCname}}"
if [ ! -x "${PYENV_ROOT}/bin/pyenv" ] ; then
rm -rf "${PYENV_ROOT}"
DOWNLOADER="wget -O-"
$DOWNLOADER --version || DOWNLOADER="curl -Lo-"
$DOWNLOADER https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
#else
# ${PYENV_ROOT}/bin/pyenv update
fi
export PATH="${PYENV_ROOT}/bin:$PATH"
eval "$(pyenv init -)"
#eval "$(pyenv virtualenv-init -)"
if [ $(uname) = Darwin ] ; then
CFLAGS="${CFLAGS} -mmacosx-version-min=10.9"
fi
INSTALL_COMMAND='eval env CFLAGS="-O2 -g -fPIC ${CFLAGS}" pyenv install -k -s "$PYENV_VERSION"'
$INSTALL_COMMAND || pyenv update && $INSTALL_COMMAND
PKG_CONFIG_PATH=$(python3-config --prefix)/lib/pkgconfig
export PKG_CONFIG_PATH
if (( "$#" == 0 )) ; then
echo "Use ${BASH_SOURCE[0]} <command-like-for-ordinary-env>"
echo "Example: "
echo "${BASH_SOURCE[0]} \"echo '\$PKG_CONFIG_PATH' && python --version\""
else
exec "$@"
fi