forked from RunestoneInteractive/pythonds
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpavement.py
95 lines (84 loc) · 3.14 KB
/
pavement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import paver
from paver.easy import *
from socket import gethostname
import paver.setuputils
paver.setuputils.install_distutils_tasks()
from os import environ
import os.path
import pkg_resources
######## CHANGE THIS ##########
project_name = "pythonds"
###############################
# if you want to override the master url do it here. Otherwise setting it to None
# configures it for the default case of wanting to use localhost for development
# and interactivepython for deployment
master_url = None
if master_url is None:
if gethostname() == 'web407.webfaction.com':
master_url = 'http://interactivepython.org'
doctrees = '../../custom_courses/{}/doctrees'.format(project_name)
else:
master_url = 'http://127.0.0.1:8000'
doctrees = './build/{}/doctrees'.format(project_name)
master_app = 'runestone'
serving_dir = './build/pythonds'
dest = '../../static'
options(
sphinx = Bunch(docroot=".",),
gettext = Bunch(
builder='gettext',
builddir='./build/'+project_name,
outdir='./locale/pot',
#templates='pkg',
sourcedir='./_sources/',
doctrees='./gettext/doctrees/',
docroot='.',
confdir=".",
warnerror=False,
template_args = {
'course_id':project_name,
}
),
build = Bunch(
builddir="./build/"+project_name,
sourcedir="./_sources/",
outdir="./build/"+project_name,
confdir=".",
project_name = project_name,
doctrees = doctrees,
template_args = {
'course_id':project_name,
'login_required':'false',
'appname':master_app,
'loglevel':10,
'course_url':master_url,
'use_services': 'true',
'python3': 'true',
'dburl': 'postgresql://bmiller@localhost/runestone',
'basecourse': 'pythonds',
}
)
)
version = pkg_resources.require("runestone")[0].version
options.build.template_args['runestone_version'] = version
# Check to see if we are building on our Jenkins build server, if so use the environment variables
# to update the DB information for this build
if 'DBHOST' in environ and 'DBPASS' in environ and 'DBUSER' in environ and 'DBNAME' in environ:
options.build.template_args['dburl'] = 'postgresql://{DBUSER}:{DBPASS}@{DBHOST}/{DBNAME}'.format(**environ)
from runestone import build # build is called implicitly by the paver driver.
@task
def gettext(options):
"Collect all translatable strings from rst input."
# Create output directory & separate doctree directory
for dir in (options.gettext.outdir, os.path.dirname(options.gettext.doctrees)):
if not os.path.exists(dir):
os.makedirs(dir)
# Extract messages (POT)
options.order('gettext', 'sphinx', add_rest=True)
from sphinxcontrib import paverutils
paverutils.run_sphinx(options, "gettext")
# Update translations PO: TODO: read conf["locale_dirs"][0] & language (es)
sh('sphinx-intl update -p "%s" --locale-dir locale -l es' % (options.gettext.outdir, ))
# Remember to build the MO files once translated:
sh('sphinx-intl build --locale-dir locale')
return