|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import os |
| 3 | +import subprocess |
| 4 | + |
| 5 | +VERSION = '3.6' |
| 6 | + |
| 7 | + |
| 8 | +def shell(cmd, capture=False, chdir=None): |
| 9 | + opts = { |
| 10 | + 'shell': True, |
| 11 | + 'stdin': subprocess.PIPE, |
| 12 | + } |
| 13 | + cwd = os.getcwd() if chdir else None |
| 14 | + if chdir: |
| 15 | + os.chdir(chdir) |
| 16 | + try: |
| 17 | + if capture: |
| 18 | + opts['stderr'] = subprocess.STDOUT |
| 19 | + opts['universal_newlines'] = True |
| 20 | + return subprocess.check_output(cmd, **opts) |
| 21 | + else: |
| 22 | + return subprocess.check_call(cmd, **opts) |
| 23 | + finally: |
| 24 | + if cwd: |
| 25 | + os.chdir(cwd) |
| 26 | + |
| 27 | + |
| 28 | +def git_clone(repository, directory, branch=None): |
| 29 | + shell("git clone --depth 1 --no-single-branch {} {}".format(repository, directory)) |
| 30 | + if branch: |
| 31 | + shell("git -C {} checkout {}".format(directory, branch)) |
| 32 | + |
| 33 | + |
| 34 | +def prepare_env(): |
| 35 | + if not os.path.exists('cpython'): |
| 36 | + git_clone('git@github.com:python/cpython.git', 'cpython', VERSION) |
| 37 | + |
| 38 | + locale_dir = os.path.join('cpython', 'locale', 'ko', 'LC_MESSAGES') |
| 39 | + if not os.path.exists(locale_dir): |
| 40 | + locale_repo = shell('git config --get remote.origin.url', capture=True).strip() |
| 41 | + git_clone(locale_repo, locale_dir, VERSION) |
| 42 | + |
| 43 | + |
| 44 | +def build(): |
| 45 | + doc_dir = os.path.join('cpython', 'Doc') |
| 46 | + shell( |
| 47 | + "make VENVDIR=../../venv SPHINXOPTS='-D locale_dirs=../locale -D language=ko -D gettext_compact=0' autobuild-stable-html", |
| 48 | + chdir=doc_dir) |
| 49 | + |
| 50 | + |
| 51 | +def main(): |
| 52 | + prepare_env() |
| 53 | + build() |
| 54 | + |
| 55 | + |
| 56 | +if __name__ == '__main__': |
| 57 | + main() |
0 commit comments