blob: 2cc3d8c2a138254dc4246e4cdcdffe68a2932867 [file] [log] [blame]
Georg Brandl34465832010-03-13 10:12:39 +00001#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4# Runs the daily build of the Python docs on dinsdale.python.org.
5#
6# Usages:
7#
Georg Brandlb70290a2012-10-28 08:18:52 +01008# dailybuild.py [-q]
Georg Brandl34465832010-03-13 10:12:39 +00009#
10# without any arguments builds docs for all branches configured in the global
Georg Brandlb70290a2012-10-28 08:18:52 +010011# BRANCHES value. -q selects "quick build", which means to build only HTML.
Georg Brandl34465832010-03-13 10:12:39 +000012#
Georg Brandlb70290a2012-10-28 08:18:52 +010013# dailybuild.py [-q] [-d] <checkout> <target>
Georg Brandl34465832010-03-13 10:12:39 +000014#
15# builds one version, where <checkout> is an SVN checkout directory of the
16# Python branch to build docs for, and <target> is the directory where the
17# result should be placed. If -d is given, the docs are built even if the
18# branch is in development mode (i.e. version contains a, b or c).
19#
20# This script is not run from the checkout, so if you want to change how the
21# daily build is run, you must replace it on dinsdale. This is necessary, for
22# example, after the release of a new minor version.
23#
24# 03/2010, Georg Brandl
25
26import os
27import sys
28import getopt
29
30
31BUILDROOT = '/home/gbrandl/docbuild'
Benjamin Peterson82c25872014-02-22 01:32:50 -050032SPHINXBUILD = os.path.join(BUILDROOT, 'sphinx-env/bin/sphinx-build')
Georg Brandl34465832010-03-13 10:12:39 +000033WWWROOT = '/data/ftp.python.org/pub/docs.python.org'
34
35BRANCHES = [
36 # checkout, target, isdev
Georg Brandl0685e142012-10-28 10:12:47 +010037 (BUILDROOT + '/python33', WWWROOT + '/3.3', False),
38 (BUILDROOT + '/python34', WWWROOT + '/3.4', True),
39 (BUILDROOT + '/python27', WWWROOT + '/2.7', False),
Georg Brandl34465832010-03-13 10:12:39 +000040]
41
42
Georg Brandlb70290a2012-10-28 08:18:52 +010043def build_one(checkout, target, isdev, quick):
Georg Brandl34465832010-03-13 10:12:39 +000044 print 'Doc autobuild started in %s' % checkout
45 os.chdir(checkout)
Georg Brandl2fbe8562012-09-30 09:03:09 +020046 print 'Running hg pull --update'
Benjamin Peterson60f07932014-02-03 13:33:56 -050047 os.system('hg pull --update')
Georg Brandl34465832010-03-13 10:12:39 +000048 print 'Running make autobuild'
Georg Brandlb70290a2012-10-28 08:18:52 +010049 maketarget = 'autobuild-' + ('html' if quick else
50 ('dev' if isdev else 'stable'))
Benjamin Peterson82c25872014-02-22 01:32:50 -050051 if os.WEXITSTATUS(os.system('cd Doc; make SPHINXBUILD=%s %s' % (SPHINXBUILD, maketarget))) == 2:
Georg Brandl34465832010-03-13 10:12:39 +000052 print '*' * 80
53 return
Georg Brandlb70290a2012-10-28 08:18:52 +010054 print 'Copying HTML files to %s' % target
Georg Brandl34465832010-03-13 10:12:39 +000055 os.system('cp -a Doc/build/html/* %s' % target)
Georg Brandlb70290a2012-10-28 08:18:52 +010056 if not quick:
57 print 'Copying dist files'
58 os.system('mkdir -p %s/archives' % target)
59 os.system('cp -a Doc/dist/* %s/archives' % target)
Georg Brandl34465832010-03-13 10:12:39 +000060 print 'Finished'
61 print '=' * 80
62
63def usage():
64 print 'Usage:'
65 print ' %s' % sys.argv[0]
66 print 'or'
67 print ' %s [-d] <checkout> <target>' % sys.argv[0]
68 sys.exit(1)
69
70
71if __name__ == '__main__':
72 try:
Georg Brandlb70290a2012-10-28 08:18:52 +010073 opts, args = getopt.getopt(sys.argv[1:], 'dq')
Georg Brandl34465832010-03-13 10:12:39 +000074 except getopt.error:
75 usage()
Georg Brandlb70290a2012-10-28 08:18:52 +010076 quick = devel = False
77 for opt, _ in opts:
78 if opt == '-q':
79 quick = True
80 if opt == '-d':
81 devel = True
82 if devel and not args:
Georg Brandl34465832010-03-13 10:12:39 +000083 usage()
84 if args:
85 if len(args) != 2:
86 usage()
Georg Brandlb70290a2012-10-28 08:18:52 +010087 build_one(args[0], args[1], devel, quick)
Georg Brandl34465832010-03-13 10:12:39 +000088 else:
Georg Brandlb70290a2012-10-28 08:18:52 +010089 for checkout, dest, devel in BRANCHES:
90 build_one(checkout, dest, devel, quick)