Skip to content

Commit 9da1d06

Browse files
authored
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()
1 parent c16ede5 commit 9da1d06

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

scripts/towncrier-draft-to-file.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
from subprocess import call
3+
4+
5+
def main():
6+
"""
7+
Platform agnostic wrapper script for towncrier.
8+
Fixes the issue (#7251) where windows users are unable to natively run tox -e docs to build pytest docs.
9+
"""
10+
with open("doc/en/_changelog_towncrier_draft.rst", "w") as draft_file:
11+
return call(("towncrier", "--draft"), stdout=draft_file)
12+
13+
14+
if __name__ == "__main__":
15+
sys.exit(main())

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ usedevelop = True
8080
deps =
8181
-r{toxinidir}/doc/en/requirements.txt
8282
towncrier
83-
whitelist_externals = sh
8483
commands =
85-
sh -c 'towncrier --draft > doc/en/_changelog_towncrier_draft.rst'
84+
python scripts/towncrier-draft-to-file.py
8685
# the '-t changelog_towncrier_draft' tags makes sphinx include the draft
8786
# changelog in the docs; this does not happen on ReadTheDocs because it uses
8887
# the standard sphinx command so the 'changelog_towncrier_draft' is never set there

0 commit comments

Comments
 (0)