.. title: A one-liner to upgrade your virtualenvs
.. slug: a-one-liner-to-upgrade-your-virtualenvs
.. date: 2018-09-23 11:02:35 UTC
.. tags: web, presentations, linux
.. category: 
.. link: 
.. description: 
.. type: text

This blog is powered by Nikola, a Python-based static blog compiler, which I've installed `in a Python virtualenv <https://cobra.pdes-net.org/posts/install-a-python-based-blog.html>`_ to separate it from the system-wide Python installation of my notebook. Updates of the major version of Python (like from 3.6 to 3.7) inevitably break these virtualenvs, and I have so far accepted that there's no other way to get them back than to rebuild them from scratch. In fact, that's what you `get to hear <https://bbs.archlinux.org/viewtopic.php?id=239439>`_ even from experienced Linux developers.

The recent update to Python 3.7 brought that topic back to my attention, and I kind of lost my patience. I just couldn't accept that there shouldn't be a better way, and indeed found a `solution <https://stackoverflow.com/questions/10218946/upgrade-python-in-a-virtualenv>`_ for those using the venv module of Python 3.3+:

::

	python -m venv --upgrade <path_of_existing_venv>

Despite the fact that I'm using virtualenv instead of venv, this command worked exactly as I had hoped. ☺

The virtualenv can now be updated as `usual. <https://cobra.pdes-net.org/posts/pip.html>`_ Well, almost – both pip and pip-tools got a lot more conservative and actually have to be told explicitly that they really should upgrade to the latest version. For a particular package, that looks like `this <https://stackoverflow.com/questions/2861183/upgrade-package-without-upgrading-dependencies-using-pip>`_:

::

	pip install --upgrade Nikola --upgrade-strategy=eager
	
A rather weird behavior, if you ask me, but what do I know. ☺

Back to our virtualenv. To really, genuinely and truly update all requirements, the following sequence of commands is necessary:

::

	pip install --upgrade setuptools
	pip install --upgrade pip
	pip install --upgrade pip-tools
	pip-compile --rebuild --upgrade --output-file requirements.txt requirements.in
	pip-sync requirements.txt
	
The update to Nikola 8.0.0 broke my old theme (based on bootstrap2), and it was about time: too many things were not working as desired. I'm now using an essentially unmodified bootblog4, as before with `Kreon <https://fonts.google.com/?category=Serif&query=Kreon>`_ as the main font, and `Muli <https://fonts.google.com/?category=Sans+Serif&query=Muli>`_ for the headlines (from 15.12.2018: `Oswald <https://fonts.google.com/?category=Sans+Serif&query=Oswald>`_ for the latter).
