- Uses
pyenv
to install setup yourpython
work environment. pyenv
support multiple paralel versions ofpython
, the exact list ofpython
versions installed by this role, as well how they are prioritized, is entirely customizable.- Finally, for each installed version of
python
,pipenv
is installed to manage the virtual enviroments
This role is only working on MacOSX & Ubuntu/Debian.
Since pyenv
is used to manage the different python
versions, it needs to be activated in your shell.
Simply add these lines to the corresponding files:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
The reason we're splitting the initialisation between these two files is to ensure smooth operation with both pyenv
and pipenv
. That way, the pyenv
activation is only done once per login shell and does not interfere with the sub-shell started with pipenv shell
.
Learn more about it: Pyenv Issue #184 - Wrong Python inside of 'pipenv shell'
-
- List of python version to install
- The order in which they are listed will be the order in why they will be prioritized via
pyenv
Learn more about it: Pyenv - Multiple Global versions - Required
- hosts: sandbox
tasks:
- include_role:
name: FlorianKempenich.python-virtualenv
vars:
python_versions:
- 3.7.0
- 2.7.15
MIT
Follow me on Twitter: @ThisIsFlorianK
Find out more about my work: Florian Kempenich - Personal Website