python-virtualenv-execute-shell

Example:

# Execute 'cookiecutter' from within a virtualenv.
- python-virtualenv-execute-shell:
    command: cookiecutter gh:audreyr/cookiecutter-pypackage --no-input
    chdir: /tmp
    virtualenv_path: /home/freckles/.pyenv/versions/cookiecutter

Description

Execute a command inside a virtualenv, the 'command' needs to be available in the virtualenv (/bin/).

You can easily use the 'execute-shell' frecklet instead of this, because for now with this you need to know the path to the virtualenv. If you used the 'python-virtualenv' frecklet and the 'python_type' 'pyenv', your virtualenv will be located under /.pyenv/versions/. In the future this will take the same vars that the 'python-virtualenv' frecklet takes, and auto-calculate the path to the virtualenv.

For now, only absolute virtualenv paths are supported, '~' won't work.

Also, this frecklet does not support commands that require user input. For this, you'd have to create a frecklet similar to this, which uses 'expect'. Not hard, just not available yet.

Variables

Name Type Default Description

command

string --

This needs to be an executable that is located in the virtualenv_path/bin/ folder. Required

virtualenv_path

string --

The (absolute) virtualenv (base) path. Required

chdir

string --

The working directory.

environment

dict --

A dictionary of environment variables to add/set.

ignore_error

boolean False

Whether to ignore any potential errors.

no_log

boolean False

Whether to hide the log of this command (because for example the command contains sensitive information).

user

string --

The user to execute this command as.

Examples

Example 1

Execute 'cookiecutter' from within a virtualenv.

Code
- python-virtualenv-execute-shell:
    command: cookiecutter gh:audreyr/cookiecutter-pypackage --no-input
    chdir: /tmp
    virtualenv_path: /home/freckles/.pyenv/versions/cookiecutter
Description

This assumes you installed cookiecutter in an virtualenv before (for example using the 'python_virtualenv' frecklet), using 'pyenv'.

The result will be a project folder at '/tmp/python_boilerplate'. Obviously, this is not that useful becaues of the '--no-input' option we used (this frecklet really only works with 'batch-able' commands).

Command-line

frecklecute python-virtualenv-execute-shell --help

Usage: frecklecute python-virtualenv-execute-shell [OPTIONS]

  Execute a command inside a virtualenv, the 'command' needs to be available
  in the virtualenv (<venv>/bin/<command>).

  You can easily use the 'execute-shell' frecklet instead of this, because
  for now with this you need to know the path to the virtualenv. If you used
  the 'python-virtualenv' frecklet and the 'python_type' 'pyenv', your
  virtualenv will be located under <user_home>/.pyenv/versions/<venv_name>.
  In the future this will take the same vars that the 'python-virtualenv'
  frecklet takes, and auto-calculate the path to the virtualenv.

  For now, only absolute virtualenv paths are supported, '~' won't work.

  Also, this frecklet does not support commands that require user input. For
  this, you'd have to create a frecklet similar to this, which uses
  'expect'. Not hard, just not available yet.

Options:
  --command COMMAND               The command to execute.  [required]
  --virtualenv-path VIRTUALENV_PATH
                                  The (absolute) virtualenv (base) path.
                                  [required]
  --chdir CHDIR                   The working directory.
  --environment ENVIRONMENT       A dictionary of environment variables to
                                  add/set.
  --ignore-error / --no-ignore-error
                                  Whether to ignore any potential errors.
  --no-log                        Whether to hide the log of this command
                                  (because for example the command contains
                                  sensitive information).
  --user USER                     The user to execute this command as.
  --help                          Show this message and exit.