Allow user to pass in no_pip, no_setuptools and no_wheel argument to the
{setup,create}_pack_virtualenv function.
@@ -39,7 +39,9 @@ __all__ = [
LOG = logging.getLogger(__name__)
-def setup_pack_virtualenv(pack_name, update=False, logger=None):
+def setup_pack_virtualenv(pack_name, update=False, logger=None, include_pip=True,
+ include_setuptools=True, include_wheel=True):
+
"""
Setup virtual environment for the provided pack.
@@ -78,7 +80,8 @@ def setup_pack_virtualenv(pack_name, update=False, logger=None):
# 1. Create virtual environment
logger.debug('Creating virtualenv for pack "%s" in "%s"' % (pack_name, virtualenv_path))
- create_virtualenv(virtualenv_path=virtualenv_path, logger=logger)
+ create_virtualenv(virtualenv_path=virtualenv_path, logger=logger, include_pip=include_pip,
+ include_setuptools=include_setuptools, include_wheel=include_wheel)
# 2. Install base requirements which are common to all the packs
logger.debug('Installing base requirements')
@@ -102,7 +105,20 @@ def setup_pack_virtualenv(pack_name, update=False, logger=None):
(pack_name, action, virtualenv_path))
-def create_virtualenv(virtualenv_path, logger=None):
+def create_virtualenv(virtualenv_path, logger=None, include_pip=True, include_setuptools=True,
+ include_wheel=True):
+ """
+ :param include_pip: Include pip binary and package in the newely created virtual environment.
+ :type include_pip: ``bool``
+
+ :param include_setuptools: Include setuptools binary and package in the newely created virtual
+ environment.
+ :type include_setuptools: ``bool``
+
+ :param include_wheel: Include wheel in the newely created virtual environment.
+ :type include_wheel : ``bool``
+ """
+
logger = logger or LOG
python_binary = cfg.CONF.actionrunner.python_binary
@@ -120,6 +136,16 @@ def create_virtualenv(virtualenv_path, logger=None):
cmd = [virtualenv_binary, '-p', python_binary]
cmd.extend(virtualenv_opts)
+
+ if not include_pip:
+ cmd.append('--no-pip')
+
+ if not include_setuptools:
+ cmd.append('--no-setuptools')
+
+ if not include_wheel:
+ cmd.append('--no-wheel')
+
cmd.extend([virtualenv_path])
logger.debug('Running command "%s" to create virtualenv.', ' '.join(cmd))
