From b862f6ff35d1611d0d63623a6254fc889012bfb9 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 27 Mar 2018 16:16:49 +0100 Subject: [PATCH] tox: Make everything work with Python 3 Nothing too fancy here except that we've to work around a really ugly side-effect of blockdiag. Change-Id: Ibd32d30aacae65702d0ccbdb8a02b1667ec4e8ee --- doc/source/conf.py | 13 +++++++++++++ tox.ini | 3 --- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 2d5ccc0d77af..61d485040515 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -181,13 +181,26 @@ def monkey_patch_blockdiag(): text width rather than on word boundaries. There's a patch submitted to resolve this [1]_ but it's unlikely to merge anytime soon. + In addition, blockdiag monkey patches a core library function, + ``codecs.getreader`` [2]_, to work around some Python 3 issues. Because + this operates in the same environment as other code that uses this library, + it ends up causing issues elsewhere. We undo these destructive changes + pending a fix. + TODO: Remove this once blockdiag is bumped to 1.6, which will hopefully include the fix. .. [1] https://bitbucket.org/blockdiag/blockdiag/pull-requests/16/ + .. [2] https://bitbucket.org/blockdiag/blockdiag/src/1.5.3/src/blockdiag/utils/compat.py # noqa """ + import codecs + from codecs import getreader + from blockdiag.imagedraw import textfolder + # oh, blockdiag. Let's undo the mess you made. + codecs.getreader = getreader + def splitlabel(text): """Split text to lines as generator. diff --git a/tox.ini b/tox.ini index 4a477cceff0a..7e88d1a833f3 100644 --- a/tox.ini +++ b/tox.ini @@ -138,9 +138,6 @@ deps = commands = {posargs} [testenv:docs] -# TODO(melwitt): This can be removed when the docs target can be run -# with python 3.x -basepython = python2.7 deps = -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/source/api doc/build api-guide/build api-ref/build placement-api-ref/build