From aee51ffdef9607835162a48a1c8e8c410aeb3389 Mon Sep 17 00:00:00 2001 From: Justin Findlay Date: Thu, 24 Sep 2015 13:26:03 -0600 Subject: [PATCH] document and check dict type for pip env_vars Fixes #27372. --- salt/modules/pip.py | 19 ++++++++++++++----- salt/states/pip_state.py | 13 ++++++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/salt/modules/pip.py b/salt/modules/pip.py index 63fdf2c136..5d3fd503f0 100644 --- a/salt/modules/pip.py +++ b/salt/modules/pip.py @@ -435,14 +435,20 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 process_dependency_links Enable the processing of dependency links - use_vt - Use VT terminal emulation (see ouptut while installing) - env_vars Set environment variables that some builds will depend on. For example, a Python C-module may have a Makefile that needs INCLUDE_PATH set to - pick up a header file while compiling. + pick up a header file while compiling. This must be in the form of a + dictionary or a mapping. + Example: + + .. code-block:: bash + + salt '*' pip.install django_app env_vars="{'CUSTOM_PATH': '/opt/django_app'}" + + use_vt + Use VT terminal emulation (see ouptut while installing) CLI Example: @@ -718,7 +724,10 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 cmd.append('--process-dependency-links') if env_vars: - os.environ.update(env_vars) + if isinstance(env_vars, dict): + os.environ.update(env_vars) + else: + raise CommandExecutionError('env_vars {0} is not a dictionary'.format(env_vars)) try: cmd_kwargs = dict(cwd=cwd, saltenv=saltenv, use_vt=use_vt, runas=user) diff --git a/salt/states/pip_state.py b/salt/states/pip_state.py index 2043b921ac..8c20c7f10e 100644 --- a/salt/states/pip_state.py +++ b/salt/states/pip_state.py @@ -387,7 +387,18 @@ def installed(name, env_vars Add or modify environment variables. Useful for tweaking build steps, such as specifying INCLUDE or LIBRARY paths in Makefiles, build scripts or - compiler calls. + compiler calls. This must be in the form of a dictionary or a mapping. + + Example: + + .. code-block:: yaml + + django: + pip.installed: + - name: django_app + - env_vars: + CUSTOM_PATH: /opt/django_app + VERBOSE: True use_vt Use VT terminal emulation (see ouptut while installing)