Installs packages in the given venv. :param str venv_name: The name or path at where the virtual environment should be created. :param pip_args: Command line arguments that should be given to pip to install packages :type pip_args: `list` of `str`
(venv_name, pip_args)
| 185 | |
| 186 | |
| 187 | def install_packages(venv_name, pip_args): |
| 188 | """Installs packages in the given venv. |
| 189 | |
| 190 | :param str venv_name: The name or path at where the virtual |
| 191 | environment should be created. |
| 192 | :param pip_args: Command line arguments that should be given to |
| 193 | pip to install packages |
| 194 | :type pip_args: `list` of `str` |
| 195 | |
| 196 | """ |
| 197 | # Using the python executable from venv, we ensure to execute following commands in this venv. |
| 198 | py_venv = get_venv_python_path(venv_name) |
| 199 | command = [py_venv, os.path.abspath('tools/pip_install.py')] |
| 200 | command.extend(pip_args) |
| 201 | subprocess_with_print(command) |
| 202 | |
| 203 | if os.path.isdir(os.path.join(venv_name, 'bin')): |
| 204 | # Linux/OSX specific |
| 205 | print('-------------------------------------------------------------------') |
| 206 | print('Please run the following command to activate developer environment:') |
| 207 | print('source {0}/bin/activate'.format(venv_name)) |
| 208 | print('-------------------------------------------------------------------') |
| 209 | elif os.path.isdir(os.path.join(venv_name, 'Scripts')): |
| 210 | # Windows specific |
| 211 | print('---------------------------------------------------------------------------') |
| 212 | print('Please run one of the following commands to activate developer environment:') |
| 213 | print('{0}\\Scripts\\activate.bat (for Batch)'.format(venv_name)) |
| 214 | print('.\\{0}\\Scripts\\Activate.ps1 (for Powershell)'.format(venv_name)) |
| 215 | print('---------------------------------------------------------------------------') |
| 216 | else: |
| 217 | raise ValueError('Error, directory {0} is not a valid venv.'.format(venv_name)) |
| 218 | |
| 219 | |
| 220 | def create_venv(venv_path): |
no test coverage detected