blob: ab4265eb9e116073f38cb933ed54ab8f5f837d70 [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'
32WWWROOT = '/data/ftp.python.org/pub/docs.python.org'
33
34BRANCHES = [
35 # checkout, target, isdev
Georg Brandl0685e142012-10-28 10:12:47 +010036 (BUILDROOT + '/python33', WWWROOT + '/3.3', False),
37 (BUILDROOT + '/python34', WWWROOT + '/3.4', True),
38 (BUILDROOT + '/python27', WWWROOT + '/2.7', False),
Georg Brandl34465832010-03-13 10:12:39 +000039]
40
41
Georg Brandlb70290a2012-10-28 08:18:52 +010042def build_one(checkout, target, isdev, quick):
Georg Brandl34465832010-03-13 10:12:39 +000043 print 'Doc autobuild started in %s' % checkout
44 os.chdir(checkout)
Georg Brandl2fbe8562012-09-30 09:03:09 +020045 print 'Running hg pull --update'
46 os.system('/usr/local/bin/hg pull --update')
Georg Brandl34465832010-03-13 10:12:39 +000047 print 'Running make autobuild'
Georg Brandlb70290a2012-10-28 08:18:52 +010048 maketarget = 'autobuild-' + ('html' if quick else
49 ('dev' if isdev else 'stable'))
50 if os.WEXITSTATUS(os.system('cd Doc; make %s' % maketarget)) == 2:
Georg Brandl34465832010-03-13 10:12:39 +000051 print '*' * 80
52 return
Georg Brandlb70290a2012-10-28 08:18:52 +010053 print 'Copying HTML files to %s' % target
Georg Brandl34465832010-03-13 10:12:39 +000054 os.system('cp -a Doc/build/html/* %s' % target)
Georg Brandlb70290a2012-10-28 08:18:52 +010055 if not quick:
56 print 'Copying dist files'
57 os.system('mkdir -p %s/archives' % target)
58 os.system('cp -a Doc/dist/* %s/archives' % target)
Georg Brandl34465832010-03-13 10:12:39 +000059 print 'Finished'
60 print '=' * 80
61
62def usage():
63 print 'Usage:'
64 print ' %s' % sys.argv[0]
65 print 'or'
66 print ' %s [-d] <checkout> <target>' % sys.argv[0]
67 sys.exit(1)
68
69
70if __name__ == '__main__':
71 try:
Georg Brandlb70290a2012-10-28 08:18:52 +010072 opts, args = getopt.getopt(sys.argv[1:], 'dq')
Georg Brandl34465832010-03-13 10:12:39 +000073 except getopt.error:
74 usage()
Georg Brandlb70290a2012-10-28 08:18:52 +010075 quick = devel = False
76 for opt, _ in opts:
77 if opt == '-q':
78 quick = True
79 if opt == '-d':
80 devel = True
81 if devel and not args:
Georg Brandl34465832010-03-13 10:12:39 +000082 usage()
83 if args:
84 if len(args) != 2:
85 usage()
Georg Brandlb70290a2012-10-28 08:18:52 +010086 build_one(args[0], args[1], devel, quick)
Georg Brandl34465832010-03-13 10:12:39 +000087 else:
Georg Brandlb70290a2012-10-28 08:18:52 +010088 for checkout, dest, devel in BRANCHES:
89 build_one(checkout, dest, devel, quick)