Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 1 | #!/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 Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 8 | # dailybuild.py [-q] |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 9 | # |
| 10 | # without any arguments builds docs for all branches configured in the global |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 11 | # BRANCHES value. -q selects "quick build", which means to build only HTML. |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 12 | # |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 13 | # dailybuild.py [-q] [-d] <checkout> <target> |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 14 | # |
| 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 | |
| 26 | import os |
| 27 | import sys |
| 28 | import getopt |
| 29 | |
| 30 | |
| 31 | BUILDROOT = '/home/gbrandl/docbuild' |
| 32 | WWWROOT = '/data/ftp.python.org/pub/docs.python.org' |
| 33 | |
| 34 | BRANCHES = [ |
| 35 | # checkout, target, isdev |
Georg Brandl | 0685e14 | 2012-10-28 10:12:47 +0100 | [diff] [blame] | 36 | (BUILDROOT + '/python33', WWWROOT + '/3.3', False), |
| 37 | (BUILDROOT + '/python34', WWWROOT + '/3.4', True), |
| 38 | (BUILDROOT + '/python27', WWWROOT + '/2.7', False), |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 39 | ] |
| 40 | |
| 41 | |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 42 | def build_one(checkout, target, isdev, quick): |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 43 | print 'Doc autobuild started in %s' % checkout |
| 44 | os.chdir(checkout) |
Georg Brandl | 2fbe856 | 2012-09-30 09:03:09 +0200 | [diff] [blame] | 45 | print 'Running hg pull --update' |
Benjamin Peterson | 60f0793 | 2014-02-03 13:33:56 -0500 | [diff] [blame^] | 46 | os.system('hg pull --update') |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 47 | print 'Running make autobuild' |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 48 | 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 Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 51 | print '*' * 80 |
| 52 | return |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 53 | print 'Copying HTML files to %s' % target |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 54 | os.system('cp -a Doc/build/html/* %s' % target) |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 55 | 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 Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 59 | print 'Finished' |
| 60 | print '=' * 80 |
| 61 | |
| 62 | def 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 | |
| 70 | if __name__ == '__main__': |
| 71 | try: |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 72 | opts, args = getopt.getopt(sys.argv[1:], 'dq') |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 73 | except getopt.error: |
| 74 | usage() |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 75 | 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 Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 82 | usage() |
| 83 | if args: |
| 84 | if len(args) != 2: |
| 85 | usage() |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 86 | build_one(args[0], args[1], devel, quick) |
Georg Brandl | 3446583 | 2010-03-13 10:12:39 +0000 | [diff] [blame] | 87 | else: |
Georg Brandl | b70290a | 2012-10-28 08:18:52 +0100 | [diff] [blame] | 88 | for checkout, dest, devel in BRANCHES: |
| 89 | build_one(checkout, dest, devel, quick) |