Skip to content

Commit 3acc8d6

Browse files
author
Michael Saki
committed
Check for pyenv earlier in the script
Since the new function, python_versions expects pyenv to be installed it makes sense to have it checked earlier in the script.
1 parent 1c21e2b commit 3acc8d6

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

setup-env

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,42 @@ END_OF_LINE
8080
exit 1
8181
fi
8282

83+
# Check to see if pyenv is installed
84+
if [ -z "$(command -v pyenv)" ] || { [ -z "$(command -v pyenv-virtualenv)" ] && [ ! -f "$(pyenv root)/plugins/pyenv-virtualenv/bin/pyenv-virtualenv" ]; }; then
85+
echo "pyenv and pyenv-virtualenv are required."
86+
if [[ "$OSTYPE" == "darwin"* ]]; then
87+
cat << 'END_OF_LINE'
88+
89+
On the Mac, we recommend installing brew, https://brew.sh/. Then installation
90+
is as simple as `brew install pyenv pyenv-virtualenv` and adding this to your
91+
profile:
92+
93+
eval "$(pyenv init -)"
94+
eval "$(pyenv virtualenv-init -)"
95+
96+
END_OF_LINE
97+
98+
fi
99+
cat << 'END_OF_LINE'
100+
For Linux, Windows Subsystem for Linux (WSL), or on the Mac (if you don't want
101+
to use "brew") you can use https://github.com/pyenv/pyenv-installer to install
102+
the necessary tools. Before running this ensure that you have installed the
103+
prerequisites for your platform according to the pyenv wiki page,
104+
https://github.com/pyenv/pyenv/wiki/common-build-problems.
105+
106+
On WSL you should treat your platform as whatever Linux distribution you've
107+
chosen to install.
108+
109+
Once you have installed "pyenv" you will need to add the following lines to
110+
your ".bashrc":
111+
112+
export PATH="$PATH:$HOME/.pyenv/bin"
113+
eval "$(pyenv init -)"
114+
eval "$(pyenv virtualenv-init -)"
115+
END_OF_LINE
116+
exit 1
117+
fi
118+
83119
# Use GNU getopt to parse options
84120
if ! PARSED=$(getopt --options $SHORTOPTS --longoptions $LONGOPTS --name "$0" -- "$@"); then
85121
echo "Error parsing options"
@@ -135,42 +171,6 @@ while true; do
135171
esac
136172
done
137173

138-
# Check to see if pyenv is installed
139-
if [ -z "$(command -v pyenv)" ] || { [ -z "$(command -v pyenv-virtualenv)" ] && [ ! -f "$(pyenv root)/plugins/pyenv-virtualenv/bin/pyenv-virtualenv" ]; }; then
140-
echo "pyenv and pyenv-virtualenv are required."
141-
if [[ "$OSTYPE" == "darwin"* ]]; then
142-
cat << 'END_OF_LINE'
143-
144-
On the Mac, we recommend installing brew, https://brew.sh/. Then installation
145-
is as simple as `brew install pyenv pyenv-virtualenv` and adding this to your
146-
profile:
147-
148-
eval "$(pyenv init -)"
149-
eval "$(pyenv virtualenv-init -)"
150-
151-
END_OF_LINE
152-
153-
fi
154-
cat << 'END_OF_LINE'
155-
For Linux, Windows Subsystem for Linux (WSL), or on the Mac (if you don't want
156-
to use "brew") you can use https://github.com/pyenv/pyenv-installer to install
157-
the necessary tools. Before running this ensure that you have installed the
158-
prerequisites for your platform according to the pyenv wiki page,
159-
https://github.com/pyenv/pyenv/wiki/common-build-problems.
160-
161-
On WSL you should treat your platform as whatever Linux distribution you've
162-
chosen to install.
163-
164-
Once you have installed "pyenv" you will need to add the following lines to
165-
your ".bashrc":
166-
167-
export PATH="$PATH:$HOME/.pyenv/bin"
168-
eval "$(pyenv init -)"
169-
eval "$(pyenv virtualenv-init -)"
170-
END_OF_LINE
171-
exit 1
172-
fi
173-
174174
# Determine the virtual environment name
175175
if [ -n "$VENV_NAME" ]; then
176176
# Use the user-provided environment name

0 commit comments

Comments
 (0)