python-virtualenv-exists
Description
Installs Python using the specified 'python_type', then uses that to create a virtualenv with the selected name and Python version. In most cases you won't use this frecklet, but the 'python-virtualenv' one, as that lets you also install python packages into the virtualenv.
If you used 'pyenv' as 'python_type', this will add a piece of code to $HOME/.bashrc
to load pyenv when the user logs in.
Variables
Name | Type | Default | Description |
---|---|---|---|
|
string | -- | The name of the virtualenv to set up. Required |
|
integer | -- | The gid of the group. |
|
string | -- | The group who owns/runs the virtualenv. |
|
string | -- | The base path to install Python into (if using 'pyenv' or 'conda'). |
|
string | -- | Build options to be forwarded (if supported by 'install_type'). |
|
string | pyenv | How to install Python. Defaults to 'pyenv'. |
|
string | latest | The version of python. |
|
boolean | False | Whether the user and group should be a system user/group. |
|
integer | -- | The uid of the user to create (optional). |
|
string | -- | The user who owns/runs the virtualenv. |
|
string | -- | The path that holds the virtualenv directory. |
|
string | -- | This only works in combination with the 'system' 'python_install_type', if used with another type, this task will fail. |
Code
doc: short_help: Create a Python virtualenv. help: | Installs Python using the specified 'python_type', then uses that to create a virtualenv with the selected name and Python version. In most cases you won't use this frecklet, but the 'python-virtualenv' one, as that lets you also install python packages into the virtualenv. If you used 'pyenv' as 'python_type', this will add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. args: venv_name: doc: short_help: The name of the virtualenv to set up. type: string required: true venv_base_path: doc: short_help: The path that holds the virtualenv directory. type: string required: false python_version: doc: short_help: The version of python. default: latest type: string python_base_path: doc: short_help: The base path to install Python into (if using 'pyenv' or 'conda'). type: string required: false user: doc: short_help: The user who owns/runs the virtualenv. type: string required: false cli: metavar: USER group: doc: short_help: The group who owns/runs the virtualenv. type: string required: false cli: metavar: GROUP system_user: doc: short_help: Whether the user and group should be a system user/group. type: boolean default: false required: false cli: show_default: true is_flag: true gid: doc: short_help: The gid of the group. type: integer required: false cli: metavar: GID uid: doc: short_help: The uid of the user to create (optional). type: integer required: false cli: metavar: UID python_type: doc: short_help: How to install Python. Defaults to 'pyenv'. type: string required: false default: pyenv allowed: - pyenv - conda - system python_build_opts: doc: short_help: Build options to be forwarded (if supported by 'install_type'). type: string required: false empty: true venv_python_exe: doc: short_help: The (optional) path to an existing Python executable to be used for the venv. help: | This only works in combination with the 'system' 'python_install_type', if used with another type, this task will fail. type: string required: false frecklets: - group-exists: frecklet::skip: '{{:: group | true_if_empty ::}}' group: '{{:: group ::}}' gid: '{{:: gid ::}}' system_group: '{{:: system_user ::}}' - user-exists: frecklet::skip: '{{:: user | true_if_empty ::}}' name: '{{:: user ::}}' uid: '{{:: uid ::}}' group: '{{:: group ::}}' system_user: '{{:: system_user ::}}' - frecklet: name: freckfrackery.python type: ansible-role resources: ansible-role: - freckfrackery.python - freckfrackery.install-pkgs - freckfrackery.install-pkg-mgrs - geerlingguy.homebrew - elliotweiser.osx-command-line-tools properties: idempotent: true internet: true elevated: true desc: short: "create virtualenv '{{:: venv_name ::}}'" references: pyenv homepage: https://github.com/pyenv/pyenv task: include-type: include vars: python_owner: '{{:: user ::}}' python_base_path: '{{:: python_base_path ::}}' python_build_opts: '{{:: python_build_opts ::}}' python_virtualenv_name: '{{:: venv_name ::}}' python_virtualenv_base: '{{:: venv_base_path ::}}' python_version: '{{:: python_version ::}}' python_type: '{{:: python_type ::}}' python_virtualenv_exe: '{{:: venv_python_exe ::}}' python_tasks: - install-python - create-virtualenv
frecklecute python-virtualenv-exists --help Usage: frecklecute python-virtualenv-exists [OPTIONS] Installs Python using the specified 'python_type', then uses that to create a virtualenv with the selected name and Python version. In most cases you won't use this frecklet, but the 'python-virtualenv' one, as that lets you also install python packages into the virtualenv. If you used 'pyenv' as 'python_type', this will add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. Options: --venv-name VENV_NAME The name of the virtualenv to set up. [required] --gid GID The gid of the group. --group GROUP The group who owns/runs the virtualenv. --python-base-path PYTHON_BASE_PATH The base path to install Python into (if using 'pyenv' or 'conda'). --python-build-opts PYTHON_BUILD_OPTS Build options to be forwarded (if supported by 'install_type'). --python-type PYTHON_TYPE How to install Python. Defaults to 'pyenv'. --python-version PYTHON_VERSION The version of python. --system-user / --no-system-user Whether the user and group should be a system user/group. --uid UID The uid of the user to create (optional). --user USER The user who owns/runs the virtualenv. --venv-base-path VENV_BASE_PATH The path that holds the virtualenv directory. --venv-python-exe VENV_PYTHON_EXE The (optional) path to an existing Python executable to be used for the venv. --help Show this message and exit.
# -*- coding: utf-8 -*- # # module path: pycklets.python_virtualenv_exists.PythonVirtualenvExists # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class PythonVirtualenvExists(AutoPycklet): """Installs Python using the specified 'python_type', then uses that to create a virtualenv with the selected name and Python version. In most cases you won't use this frecklet, but the 'python-virtualenv' one, as that lets you also install python packages into the virtualenv. If you used 'pyenv' as 'python_type', this will add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. Args: gid: The gid of the group. group: The group who owns/runs the virtualenv. python_base_path: The base path to install Python into (if using 'pyenv' or 'conda'). python_build_opts: Build options to be forwarded (if supported by 'install_type'). python_type: How to install Python. Defaults to 'pyenv'. python_version: The version of python. system_user: Whether the user and group should be a system user/group. uid: The uid of the user to create (optional). user: The user who owns/runs the virtualenv. venv_base_path: The path that holds the virtualenv directory. venv_name: The name of the virtualenv to set up. venv_python_exe: The (optional) path to an existing Python executable to be used for the venv. """ FRECKLET_ID = "python-virtualenv-exists" gid: int = None group: str = None python_base_path: str = None python_build_opts: str = None python_type: str = None python_version: str = None system_user: bool = None uid: int = None user: str = None venv_base_path: str = None venv_name: str = None venv_python_exe: str = None def __post_init__(self): super(PythonVirtualenvExists, self).__init__(var_names=["gid", "group", "python_base_path", "python_build_opts", "python_type", "python_version", "system_user", "uid", "user", "venv_base_path", "venv_name", "venv_python_exe"]) frecklet_class = PythonVirtualenvExists
# -*- coding: utf-8 -*- # # module path: pycklets.python_virtualenv_exists.PythonVirtualenvExists # from pyckles import AutoPycklet class PythonVirtualenvExists(AutoPycklet): """Installs Python using the specified 'python_type', then uses that to create a virtualenv with the selected name and Python version. In most cases you won't use this frecklet, but the 'python-virtualenv' one, as that lets you also install python packages into the virtualenv. If you used 'pyenv' as 'python_type', this will add a piece of code to ``$HOME/.bashrc`` to load pyenv when the user logs in. Args: gid: The gid of the group. group: The group who owns/runs the virtualenv. python_base_path: The base path to install Python into (if using 'pyenv' or 'conda'). python_build_opts: Build options to be forwarded (if supported by 'install_type'). python_type: How to install Python. Defaults to 'pyenv'. python_version: The version of python. system_user: Whether the user and group should be a system user/group. uid: The uid of the user to create (optional). user: The user who owns/runs the virtualenv. venv_base_path: The path that holds the virtualenv directory. venv_name: The name of the virtualenv to set up. venv_python_exe: The (optional) path to an existing Python executable to be used for the venv. """ FRECKLET_ID = "python-virtualenv-exists" def __init__(self, gid=None, group=None, python_base_path=None, python_build_opts=None, python_type="pyenv", python_version="latest", system_user=None, uid=None, user=None, venv_base_path=None, venv_name=None, venv_python_exe=None): super(PythonVirtualenvExists, self).__init__(var_names=["gid", "group", "python_base_path", "python_build_opts", "python_type", "python_version", "system_user", "uid", "user", "venv_base_path", "venv_name", "venv_python_exe"]) self._gid = gid self._group = group self._python_base_path = python_base_path self._python_build_opts = python_build_opts self._python_type = python_type self._python_version = python_version self._system_user = system_user self._uid = uid self._user = user self._venv_base_path = venv_base_path self._venv_name = venv_name self._venv_python_exe = venv_python_exe @property def gid(self): return self._gid @gid.setter def gid(self, gid): self._gid = gid @property def group(self): return self._group @group.setter def group(self, group): self._group = group @property def python_base_path(self): return self._python_base_path @python_base_path.setter def python_base_path(self, python_base_path): self._python_base_path = python_base_path @property def python_build_opts(self): return self._python_build_opts @python_build_opts.setter def python_build_opts(self, python_build_opts): self._python_build_opts = python_build_opts @property def python_type(self): return self._python_type @python_type.setter def python_type(self, python_type): self._python_type = python_type @property def python_version(self): return self._python_version @python_version.setter def python_version(self, python_version): self._python_version = python_version @property def system_user(self): return self._system_user @system_user.setter def system_user(self, system_user): self._system_user = system_user @property def uid(self): return self._uid @uid.setter def uid(self, uid): self._uid = uid @property def user(self): return self._user @user.setter def user(self, user): self._user = user @property def venv_base_path(self): return self._venv_base_path @venv_base_path.setter def venv_base_path(self, venv_base_path): self._venv_base_path = venv_base_path @property def venv_name(self): return self._venv_name @venv_name.setter def venv_name(self, venv_name): self._venv_name = venv_name @property def venv_python_exe(self): return self._venv_python_exe @venv_python_exe.setter def venv_python_exe(self, venv_python_exe): self._venv_python_exe = venv_python_exe frecklet_class = PythonVirtualenvExists