MCPcopy Create free account
hub / github.com/StackStorm/st2 / create_virtualenv

Function create_virtualenv

st2common/st2common/util/virtualenvs.py:170–246  ·  view source on GitHub ↗

: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_setupto

(
    virtualenv_path,
    logger=None,
    include_pip=True,
    include_setuptools=True,
    include_wheel=True,
    no_download=True,
)

Source from the content-addressed store, hash-verified

168
169
170def create_virtualenv(
171 virtualenv_path,
172 logger=None,
173 include_pip=True,
174 include_setuptools=True,
175 include_wheel=True,
176 no_download=True,
177):
178 """
179 :param include_pip: Include pip binary and package in the newely created virtual environment.
180 :type include_pip: ``bool``
181
182 :param include_setuptools: Include setuptools binary and package in the newely created virtual
183 environment.
184 :type include_setuptools: ``bool``
185
186 :param include_wheel: Include wheel in the newely created virtual environment.
187 :type include_wheel : ``bool``
188
189 :param no_download: Do not download and install latest version of pre-installed packages such
190 as pip and setuptools.
191 :type no_download: ``bool``
192 """
193
194 logger = logger or LOG
195
196 python_binary = cfg.CONF.actionrunner.python_binary
197 virtualenv_binary = cfg.CONF.actionrunner.virtualenv_binary
198 virtualenv_opts = cfg.CONF.actionrunner.virtualenv_opts or []
199 virtualenv_opts += ["--verbose"]
200
201 if not os.path.isfile(python_binary):
202 raise Exception('Python binary "%s" doesn\'t exist' % (python_binary))
203
204 if not os.path.isfile(virtualenv_binary):
205 raise Exception('Virtualenv binary "%s" doesn\'t exist.' % (virtualenv_binary))
206
207 logger.debug(
208 'Creating virtualenv in "%s" using Python binary "%s"'
209 % (virtualenv_path, python_binary)
210 )
211
212 cmd = [virtualenv_binary]
213
214 cmd.extend(["-p", python_binary])
215
216 cmd.extend(virtualenv_opts)
217
218 if not include_pip:
219 cmd.append("--no-pip")
220
221 if not include_setuptools:
222 cmd.append("--no-setuptools")
223
224 if not include_wheel:
225 cmd.append("--no-wheel")
226
227 if no_download:

Callers 1

setup_pack_virtualenvFunction · 0.85

Calls 1

run_commandFunction · 0.90

Tested by

no test coverage detected