mdklatt.python3
####### python3 #######
|travis.png|
This Ansible role_ will set up Python 3, pip, and virtualenv.
Even though pip and virtualenv tools will be added, it's better to use them as modules to make sure you are using the correct version:
.. code-block:: console
$ python3 -m pip install <package>
$ python3 -m venv <dir>
This role assumes that the user is using bash as their shell and will change the startup files accordingly.
By default, Python will be installed from packages. If the python3_pyenv variable is set, pyenv_ will be installed and will help install the specified version of Python - even from source if needed. A pyenv_ installation is only available for the current Ansible user (the login user by default). The role will not activate the new Python version; refer to the pyenv_ documentation for instructions on how to do this.
You can also find this role on Ansible Galaxy_.
============== Using the Role ==============
Role Variables
python3_command: Name of the Python commandpython3_shellrc: File to modify for login; defaults to.bash_profilepython3_local: Local directory for binaries; varies by systempython3_pyenv: Python version to install usingpyenv_
Example Playbook
.. code-block:: yaml
- hosts: all
roles:
- name: python3
python3_pyenv: "3.8.5"
===========
Development
===========
Use the task script to perform development tasks:
dev: Set up the local development environmenttest: Run theMolecule_ testing suite
.. |travis.png| image:: https://travis-ci.org/mdklatt/ansible-python3-role.svg?branch=main
:alt: Travis CI build status
:target: travis_
.. _travis: https://travis-ci.org/mdklatt/ansible-python3-role
.. _Ansible role: http://docs.ansible.com/ansible/playbooks_roles.html#roles
.. _Ansible Galaxy: https://galaxy.ansible.com/mdklatt/python3
.. _pyenv: https://github.com/pyenv/pyenv
.. _Molecule: https://molecule.readthedocs.io/en/stable/getting-started.html#run-a-full-test-sequence
ansible-galaxy install mdklatt.python3