Release script: build command

This commit is contained in:
Adrian Sampson 2014-05-02 09:56:14 -07:00
parent 064013605a
commit 1613f9b773
2 changed files with 25 additions and 0 deletions

View file

@ -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

View file

@ -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()