Accept --upgrade-strategy
arg for pip()
and mkvirtualenv()
This commit is contained in:
parent
b3f4d1ea35
commit
86429d4f06
|
@ -30,7 +30,7 @@ from contextlib import contextmanager
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from fabric.api import sudo, run, prefix, cd, settings, env
|
from fabric.api import abort, sudo, run, prefix, cd, settings, env
|
||||||
from fabric.contrib.files import exists, append
|
from fabric.contrib.files import exists, append
|
||||||
|
|
||||||
from rattail_fabric import apt, mkdir
|
from rattail_fabric import apt, mkdir
|
||||||
|
@ -54,12 +54,17 @@ def install_pip(use_apt=False):
|
||||||
pip('pip', 'wheel', 'ndg-httpsclient')
|
pip('pip', 'wheel', 'ndg-httpsclient')
|
||||||
|
|
||||||
|
|
||||||
def pip(*packages):
|
def pip(*packages, **kwargs):
|
||||||
"""
|
"""
|
||||||
Install one or more packages via ``pip install``.
|
Install one or more packages via ``pip install``.
|
||||||
"""
|
"""
|
||||||
packages = ["'{0}'".format(p) for p in packages]
|
upgrade_strategy = kwargs.pop('upgrade_strategy', '')
|
||||||
sudo('pip install --upgrade {0}'.format(' '.join(packages)))
|
if upgrade_strategy:
|
||||||
|
upgrade_strategy = '--upgrade-strategy {}'.format(upgrade_strategy)
|
||||||
|
if kwargs:
|
||||||
|
abort("Unknown kwargs for pip(): {}".format(kwargs))
|
||||||
|
packages = ["'{}'".format(p) for p in packages]
|
||||||
|
sudo('pip install --upgrade {} {}'.format(upgrade_strategy, ' '.join(packages)))
|
||||||
|
|
||||||
|
|
||||||
def install_virtualenvwrapper(workon_home=None, user='root', use_apt=False):
|
def install_virtualenvwrapper(workon_home=None, user='root', use_apt=False):
|
||||||
|
@ -99,7 +104,8 @@ def configure_virtualenvwrapper(user, workon_home=None, wrapper='/usr/local/bin/
|
||||||
update('.bashrc')
|
update('.bashrc')
|
||||||
|
|
||||||
|
|
||||||
def mkvirtualenv(name, python=None, user=None, workon_home=None, upgrade_pip=True):
|
def mkvirtualenv(name, python=None, user=None, workon_home=None,
|
||||||
|
upgrade_pip=True, upgrade_setuptools=True, upgrade_strategy=None):
|
||||||
"""
|
"""
|
||||||
Make a new Python virtual environment.
|
Make a new Python virtual environment.
|
||||||
"""
|
"""
|
||||||
|
@ -112,7 +118,9 @@ def mkvirtualenv(name, python=None, user=None, workon_home=None, upgrade_pip=Tru
|
||||||
pip_req = 'pip'
|
pip_req = 'pip'
|
||||||
with workon(name):
|
with workon(name):
|
||||||
pip('six')
|
pip('six')
|
||||||
pip(pip_req, 'setuptools', 'wheel', 'ndg-httpsclient')
|
pip(pip_req)
|
||||||
|
if upgrade_setuptools:
|
||||||
|
pip('setuptools', 'wheel', 'ndg-httpsclient', upgrade_strategy=upgrade_strategy)
|
||||||
if user:
|
if user:
|
||||||
with cdvirtualenv(name, workon_home=workon_home):
|
with cdvirtualenv(name, workon_home=workon_home):
|
||||||
mkdir('app/log', owner='{0}:{0}'.format(user))
|
mkdir('app/log', owner='{0}:{0}'.format(user))
|
||||||
|
|
Loading…
Reference in a new issue