pyenv-python-installed

Example:

# Install the latest version of Python.
- pyenv-python-installed

Description

Note: this is mostly deprecated now by the 'python-lang-installed' frecklet.

Install a Python environment for a user, using pyenv.

This will install all dependencies required to build Python, then it will download the specified version of Python, compile it, and use the 'pyenv global' command (which will write that information into the file $HOME/.pyenv/version) to make it the default version for the user.

It will also add a piece of code to $HOME/.bashrc to load pyenv when the user logs in. If you use this to install Python for a user different to the executing one, make sure to specify the 'path' argument (absolute path required, relative or using '~'/'$HOME' won't work).

Resources

Variables

Name Type Default Description

path

string --

Defaults to $HOME/.pyenv

set_global

boolean True

Don't set 'global' version.

user

string --

The user to install pyenv for.

version

n/a 3.7.3

The version of Python to install.

Examples

Example 1

Install the latest version of Python.

Code
- pyenv-python-installed

Example 2

Install Python version 3.6.8 for user 'freckles'.

Code
- pyenv-python-installed:
    version: 3.6.8
    user: freckles
Description

The user 'freckles' will be created if it doesn't exist yet.

Code

doc:
  short_help: Install a Python runtime for a user via 'pyenv'.
  help: |
    **Note**: this is mostly deprecated now by the 'python-lang-installed' frecklet.

    Install a Python environment for a user, using [pyenv](https://github.com/pyenv/pyenv).

    This will install all dependencies required to build Python, then it will download the specified version of Python,
    compile it, and use the 'pyenv global' command (which will write that information into the file $HOME/.pyenv/version)
    to make it the default version for the user.

    It will also add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. If you use this to install
    Python for a user different to the executing one, make sure to specify the 'path' argument (absolute path required,
    relative or using '~'/'$HOME' won't work).
  references:
    pyenv homepage: https://github.com/pyenv/pyenv
    "'avanov.pyenv' Ansible role": https://github.com/avanov/ansible-galaxy-pyenv
  examples:
  - title: Install the latest version of Python.
  - title: Install Python version 3.6.8 for user 'freckles'.
    desc: The user 'freckles' will be created if it doesn't exist yet.
    vars:
      version: 3.6.8
      user: freckles

args:
  version:
    doc:
      short_help: The version of Python to install.
    default: 3.7.3
    required: true
  user:
    doc:
      short_help: The user to install pyenv for.
    type: string
    required: false
  path:
    doc:
      short_help: The path to install pyenv into.
      help: |
        Defaults to $HOME/.pyenv
    type: string
    required: false
  set_global:
    doc:
      short_help: Don't set 'global' version.
    type: boolean
    required: false
    default: true

frecklets:
- user-exists:
    frecklet::skip: '{{:: user | true_if_empty ::}}'
    name: '{{:: user ::}}'
- frecklet:
    name: avanov.pyenv
    type: ansible-role
    properties:
      idempotent: true
      internet: true
      elevated: true
    desc:
      references:
        "'avanov.pyenv' Ansible role": https://github.com/avanov/ansible-galaxy-pyenv
        pyenv homepage: https://github.com/pyenv/pyenv
  task:
    include-type: include
#      become: true
  vars:
    pyenv_env: user
    pyenv_path: '{{:: path ::}}'
    pyenv_owner: '{{:: user ::}}'
    pyenv_global: '{%:: if set_global ::%}{{:: version ::}}{%:: endif ::%}'
    pyenv_virtualenvs: []
    pyenv_python_versions:
    - '{{:: version::}}'
frecklecute --community pyenv-python-installed --help

Usage: frecklecute pyenv-python-installed [OPTIONS]

  **Note**: this is mostly deprecated now by the 'python-lang-installed'
  frecklet.

  Install a Python environment for a user, using
  [pyenv](https://github.com/pyenv/pyenv).

  This will install all dependencies required to build Python, then it will
  download the specified version of Python, compile it, and use the 'pyenv
  global' command (which will write that information into the file
  $HOME/.pyenv/version) to make it the default version for the user.

  It will also add a piece of code to ``$HOME/.bashrc`` to load pyenv when
  the user logs in. If you use this to install Python for a user different
  to the executing one, make sure to specify the 'path' argument (absolute
  path required, relative or using '~'/'$HOME' won't work).

Options:
  --path PATH                     The path to install pyenv into.
  --set-global / --no-set-global  Don't set 'global' version.
  --user USER                     The user to install pyenv for.
  --version VERSION               The version of Python to install.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.pyenv_python_installed.PyenvPythonInstalled
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class PyenvPythonInstalled(AutoPycklet):
    """**Note**: this is mostly deprecated now by the 'python-lang-installed' frecklet.

     Install a Python environment for a user, using [pyenv](https://github.com/pyenv/pyenv).

     This will install all dependencies required to build Python, then it will download the specified version of Python,
     compile it, and use the 'pyenv global' command (which will write that information into the file $HOME/.pyenv/version)
     to make it the default version for the user.

     It will also add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. If you use this to install
     Python for a user different to the executing one, make sure to specify the 'path' argument (absolute path required,
     relative or using '~'/'$HOME' won't work).

       Args:
         path: The path to install pyenv into.
         set_global: Don't set 'global' version.
         user: The user to install pyenv for.
         version: The version of Python to install.

    """

    FRECKLET_ID = "pyenv-python-installed"

    path: str = None
    set_global: bool = None
    user: str = None
    version: str = None


    def __post_init__(self):
        super(PyenvPythonInstalled, self).__init__(var_names=["path", "set_global", "user", "version"])


frecklet_class = PyenvPythonInstalled
# -*- coding: utf-8 -*-


#
# module path: pycklets.pyenv_python_installed.PyenvPythonInstalled
#


from pyckles import AutoPycklet

class PyenvPythonInstalled(AutoPycklet):
    """**Note**: this is mostly deprecated now by the 'python-lang-installed' frecklet.

     Install a Python environment for a user, using [pyenv](https://github.com/pyenv/pyenv).

     This will install all dependencies required to build Python, then it will download the specified version of Python,
     compile it, and use the 'pyenv global' command (which will write that information into the file $HOME/.pyenv/version)
     to make it the default version for the user.

     It will also add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. If you use this to install
     Python for a user different to the executing one, make sure to specify the 'path' argument (absolute path required,
     relative or using '~'/'$HOME' won't work).

       Args:
         path: The path to install pyenv into.
         set_global: Don't set 'global' version.
         user: The user to install pyenv for.
         version: The version of Python to install.

    """

    FRECKLET_ID = "pyenv-python-installed"

    def __init__(self, path=None, set_global=True, user=None, version="3.7.3"):

        super(PyenvPythonInstalled, self).__init__(var_names=["path", "set_global", "user", "version"])
        self._path = path
        self._set_global = set_global
        self._user = user
        self._version = version

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

    @property
    def set_global(self):
        return self._set_global

    @set_global.setter
    def set_global(self, set_global):
        self._set_global = set_global

    @property
    def user(self):
        return self._user

    @user.setter
    def user(self, user):
        self._user = user

    @property
    def version(self):
        return self._version

    @version.setter
    def version(self, version):
        self._version = version



frecklet_class = PyenvPythonInstalled