@@ -11,36 +11,59 @@ runs:
1111 - name : Checkout code
1212 uses : actions/checkout@v4
1313
14- - name : Install .python-version and ${{ inputs.python-version }}
15- uses : " gabrielfalcao/pyenv-action@v18"
16- with :
17- default : 3.7.17
18- versions : ${{ inputs.python-version }}
14+ - name : Install pyenv from source
15+ run : |
16+ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
17+ echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
18+ echo "$HOME/.pyenv/bin" >> $GITHUB_PATH
19+ shell : bash
1920
20- - name : Switch to .python-version
21+ - name : Install Python ${{ inputs .python-version }} via pyenv
2122 run : |
22- pyenv local "$(cat .python-version)"
23- if python -V | grep -q "$(cat .python-version)"; then
24- echo "Python version is '$(python -V)'"
25- else
26- echo "Python version is '$(python -V)', but should be '$(cat .python-version)'. Exiting workflow."
23+ export PYENV_ROOT="$HOME/.pyenv"
24+ export PATH="$PYENV_ROOT/bin:$PATH"
25+ eval "$(pyenv init --path)"
26+ pyenv install -s ${{ inputs.python-version }}
27+ pyenv global ${{ inputs.python-version }}
28+ echo "${{ inputs.python-version }}" > .python-version
29+ shell : bash
30+
31+ - name : Verify installed Python version
32+ run : |
33+ export PYENV_ROOT="$HOME/.pyenv"
34+ export PATH="$PYENV_ROOT/bin:$PATH"
35+ eval "$(pyenv init --path)"
36+ ACTUAL=$(python -V)
37+ EXPECTED=${{ inputs.python-version }}
38+ echo "Python version installed: $ACTUAL"
39+ if ! python -V | grep -q "$EXPECTED"; then
40+ echo "Python version is not correct. Exiting."
2741 exit 1
2842 fi
2943 shell : bash
3044
3145 - name : Install pipenv
3246 run : |
47+ export PYENV_ROOT="$HOME/.pyenv"
48+ export PATH="$PYENV_ROOT/bin:$PATH"
49+ eval "$(pyenv init --path)"
3350 python -m pip install --upgrade pip
3451 pip install pipenv
3552 shell : bash
3653
3754 - name : Setup virtual environment
3855 run : |
56+ export PYENV_ROOT="$HOME/.pyenv"
57+ export PATH="$PYENV_ROOT/bin:$PATH"
58+ eval "$(pyenv init --path)"
3959 pipenv --python ${{ inputs.python-version }} install --dev --deploy
4060 shell : bash
4161
4262 - name : Verify virtual environment uses python version ${{ inputs.python-version }}
4363 run : |
64+ export PYENV_ROOT="$HOME/.pyenv"
65+ export PATH="$PYENV_ROOT/bin:$PATH"
66+ eval "$(pyenv init --path)"
4467 if pipenv run python -V | grep -q "${{ inputs.python-version }}"; then
4568 echo "Python ${{ inputs.python-version }} is being used."
4669 else
5174
5275 - name : Run unittests
5376 run : |
77+ export PYENV_ROOT="$HOME/.pyenv"
78+ export PATH="$PYENV_ROOT/bin:$PATH"
79+ eval "$(pyenv init --path)"
5480 PYTHONPATH=./src:./tests pipenv run pytest ./tests
5581 shell : bash
0 commit comments