From 1613f9b77342b396fef4fbaac82aaec4b9c876f1 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 2 May 2014 09:56:14 -0700 Subject: [PATCH] Release script: build command --- docs/Makefile | 5 +++++ extra/release.py | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/Makefile b/docs/Makefile index 3484f95c4..3c8aa63d6 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build +# When both are available, use Sphinx 2.x for autodoc compatibility. +ifeq ($(shell which sphinx-build2 >/dev/null 2>&1 ; echo $$?),0) + SPHINXBUILD = sphinx-build2 +endif + # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter diff --git a/extra/release.py b/extra/release.py index b1c7daa44..d51500350 100644 --- a/extra/release.py +++ b/extra/release.py @@ -4,10 +4,22 @@ import click import os import re +import subprocess +from contextlib import contextmanager BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +@contextmanager +def chdir(d): + """A context manager that temporary changes the working directory. + """ + olddir = os.getcwd() + os.chdir(d) + yield + os.chdir(olddir) + + @click.group() def release(): pass @@ -108,5 +120,13 @@ def bump(version): f.write(contents) +@release.command() +def build(): + """Use `setup.py` to build a source tarball. + """ + with chdir(BASE): + subprocess.check_call(['python2', 'setup.py', 'sdist']) + + if __name__ == '__main__': release()