updated pip.install command
This commit is contained in:
parent
e1332b7d00
commit
9c00c3b10e
1 changed files with 18 additions and 9 deletions
|
|
@ -1,13 +1,14 @@
|
|||
from fabric.api import env, task
|
||||
from fabric.operations import run
|
||||
from fabric.context_managers import hide, settings
|
||||
from fabric.utils import abort
|
||||
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
from .utils import virtualenv_source, virtualenv
|
||||
from .utils import print_console, printerr
|
||||
from .utils import printerr
|
||||
|
||||
ERROR_BAD_BRANCH_PARAM = -3
|
||||
ERROR_BAD_PARAM = -2
|
||||
|
|
@ -122,25 +123,33 @@ def setup():
|
|||
|
||||
|
||||
@task
|
||||
def install(package=None):
|
||||
def install(package_name=None):
|
||||
"""
|
||||
install a packages via pip
|
||||
Installs a package via pip within a virtual environment.
|
||||
|
||||
This method installs a specified package using pip. If the package_name
|
||||
is '--all', it installs all packages listed in the requirements file.
|
||||
|
||||
:param package_name: Name of the package to install or '--all' to install
|
||||
all packages from requirements file, defaults to None.
|
||||
:type package_name: str, optional
|
||||
|
||||
:raises ValueError: If no package_name is provided.
|
||||
"""
|
||||
configuration = env.config
|
||||
|
||||
if not package:
|
||||
printerr("You must specify a package to be installed", ERROR_BAD_PARAM)
|
||||
if not package_name:
|
||||
abort("You must specify a package name to be installed")
|
||||
|
||||
if package == "--all":
|
||||
if package_name == "--all":
|
||||
pipinstall_cmd = "pip install -r {requirements_file}".format(
|
||||
requirements_file=configuration.virtualenv.requirements.filepath)
|
||||
else:
|
||||
pipinstall_cmd = "pip install {package}".format(
|
||||
package=package)
|
||||
package=package_name)
|
||||
|
||||
if env.debug:
|
||||
print_console("pipinstall_cmd : %s" % pipinstall_cmd)
|
||||
|
||||
print("pipinstall_cmd: %s" % pipinstall_cmd)
|
||||
else:
|
||||
with virtualenv():
|
||||
run(pipinstall_cmd)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue