From 9da1d0687ea02b724ad27c1caafc58651e01ee5a Mon Sep 17 00:00:00 2001 From: Simon K Date: Sun, 31 May 2020 16:11:11 +0100 Subject: [PATCH] adding towncrier wrapper script so 'tox -e docs' works natively on windows (#7266) * enable tox -e docs natively on windows using a wrapper * rename the towncrier script; run the towncrier command in a safer manner * use subprocess.call; call exit() around main on towncrier wrapper * change to sys.exit() instead of builtin exit() --- scripts/towncrier-draft-to-file.py | 15 +++++++++++++++ tox.ini | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 scripts/towncrier-draft-to-file.py diff --git a/scripts/towncrier-draft-to-file.py b/scripts/towncrier-draft-to-file.py new file mode 100644 index 000000000..81507b40b --- /dev/null +++ b/scripts/towncrier-draft-to-file.py @@ -0,0 +1,15 @@ +import sys +from subprocess import call + + +def main(): + """ + Platform agnostic wrapper script for towncrier. + Fixes the issue (#7251) where windows users are unable to natively run tox -e docs to build pytest docs. + """ + with open("doc/en/_changelog_towncrier_draft.rst", "w") as draft_file: + return call(("towncrier", "--draft"), stdout=draft_file) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tox.ini b/tox.ini index f363f5701..8e1a51ca7 100644 --- a/tox.ini +++ b/tox.ini @@ -80,9 +80,8 @@ usedevelop = True deps = -r{toxinidir}/doc/en/requirements.txt towncrier -whitelist_externals = sh commands = - sh -c 'towncrier --draft > doc/en/_changelog_towncrier_draft.rst' + python scripts/towncrier-draft-to-file.py # the '-t changelog_towncrier_draft' tags makes sphinx include the draft # changelog in the docs; this does not happen on ReadTheDocs because it uses # the standard sphinx command so the 'changelog_towncrier_draft' is never set there