Do *not* pass --upgrade flag by default, for pip install

must now specify pip('pkg', upgrade=True) if you want an upgrade
This commit is contained in:
Lance Edgar 2018-07-06 17:41:33 -05:00
parent c658cd5c38
commit e542f45638

View file

@ -50,21 +50,26 @@ def install_pip(use_apt=False):
apt.install('python-pkg-resources', 'python-setuptools') apt.install('python-pkg-resources', 'python-setuptools')
sudo('easy_install pip') sudo('easy_install pip')
sudo('apt-get --assume-yes purge python-setuptools') sudo('apt-get --assume-yes purge python-setuptools')
pip('setuptools') pip('setuptools')
pip('pip', 'wheel', 'ndg-httpsclient') pip('pip', upgrade=True)
pip('setuptools', 'wheel', 'ndg-httpsclient', upgrade=True, upgrade_strategiy='eager')
def pip(*packages, **kwargs): def pip(*packages, **kwargs):
""" """
Install one or more packages via ``pip install``. Install one or more packages via ``pip install``.
""" """
upgrade = kwargs.pop('upgrade', False)
upgrade = '--upgrade' if upgrade else ''
upgrade_strategy = kwargs.pop('upgrade_strategy', None) upgrade_strategy = kwargs.pop('upgrade_strategy', None)
if upgrade_strategy: if upgrade and upgrade_strategy:
upgrade_strategy = '--upgrade-strategy {}'.format(upgrade_strategy) upgrade_strategy = '--upgrade-strategy {}'.format(upgrade_strategy)
else:
upgrade_strategy = ''
if kwargs: if kwargs:
abort("Unknown kwargs for pip(): {}".format(kwargs)) abort("Unknown kwargs for pip(): {}".format(kwargs))
packages = ["'{}'".format(p) for p in packages] packages = ["'{}'".format(p) for p in packages]
sudo('pip install --upgrade {} {}'.format(upgrade_strategy or '', ' '.join(packages))) sudo('pip install {} {} {}'.format(upgrade, 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):
@ -77,7 +82,7 @@ def install_virtualenvwrapper(workon_home=None, user='root', use_apt=False):
if use_apt: if use_apt:
apt.install('virtualenvwrapper') apt.install('virtualenvwrapper')
else: else:
pip('virtualenvwrapper') pip('virtualenvwrapper', upgrade=True)
configure_virtualenvwrapper('root', workon_home) configure_virtualenvwrapper('root', workon_home)
if user != 'root': if user != 'root':
configure_virtualenvwrapper(user, workon_home) configure_virtualenvwrapper(user, workon_home)
@ -117,10 +122,10 @@ def mkvirtualenv(name, python=None, user=None, workon_home=None,
else: else:
pip_req = 'pip' pip_req = 'pip'
with workon(name): with workon(name):
pip('six') pip('six', upgrade=True)
pip(pip_req) pip(pip_req, upgrade=True)
if upgrade_setuptools: if upgrade_setuptools:
pip('setuptools', 'wheel', 'ndg-httpsclient', upgrade_strategy=upgrade_strategy) pip('setuptools', 'wheel', 'ndg-httpsclient', upgrade=True, 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))