|
|
@ -14,19 +14,24 @@ __all__ = ( |
|
|
|
# Functions |
|
|
|
# Functions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def python_pip(name, op="install", upgrade=False, venv=None, **kwargs): |
|
|
|
def python_pip(name, op="install", upgrade=False, venv=None, version=3, **kwargs): |
|
|
|
"""Use pip to install or uninstall a Python package. |
|
|
|
"""Use pip to install or uninstall a Python package. |
|
|
|
|
|
|
|
|
|
|
|
- name (str): The name of the package. |
|
|
|
- name (str): The name of the package. |
|
|
|
- op (str): The operation to perform; install, uninstall |
|
|
|
- op (str): The operation to perform; install, uninstall |
|
|
|
- upgrade (bool): Upgrade an installed package. |
|
|
|
- upgrade (bool): Upgrade an installed package. |
|
|
|
- venv (str): The name of the virtual environment to load. |
|
|
|
- venv (str): The name of the virtual environment to load. |
|
|
|
|
|
|
|
- version (int): The Python version to use, e.g. ``2`` or ``3``. |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
manager = "pip" |
|
|
|
|
|
|
|
if version == 3: |
|
|
|
|
|
|
|
manager = "pip3" |
|
|
|
|
|
|
|
|
|
|
|
if upgrade: |
|
|
|
if upgrade: |
|
|
|
statement = "pip install --upgrade %s" % name |
|
|
|
statement = "%s install --upgrade %s" % (manager, name) |
|
|
|
else: |
|
|
|
else: |
|
|
|
statement = "pip %s %s" % (op, name) |
|
|
|
statement = "%s %s %s" % (manager, op, name) |
|
|
|
|
|
|
|
|
|
|
|
if venv is not None: |
|
|
|
if venv is not None: |
|
|
|
kwargs['prefix'] = "source %s/bin/activate" % venv |
|
|
|
kwargs['prefix'] = "source %s/bin/activate" % venv |
|
|
|