-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpavement.py
129 lines (113 loc) · 3.33 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright (c) 2010-2013 Adi Roiban.
# See LICENSE for details.
"""
Build script for Python binary distribution.
"""
import compileall
import os
import py_compile
from brink.pavement_commons import (
buildbot_list,
buildbot_try,
default,
github,
harness,
help,
pave,
SETUP,
test_remote,
test_review,
)
from paver.easy import task
# Make pylint shut up.
buildbot_list
buildbot_try
default
github
harness
help
test_remote
test_review
SETUP['product']['name'] = 'python'
SETUP['folders']['source'] = u'src'
SETUP['repository']['name'] = u'python-package'
SETUP['test']['package'] = None
SETUP['pypi']['index_url'] = os.environ['PIP_INDEX_URL']
SETUP['repository']['name'] = u'python-package'
SETUP['repository']['github'] = 'https://github.com/chevah/python-package'
RUN_PACKAGES = [
'zope.interface==3.8.0',
'twisted==15.5.0.chevah7',
# Required for some unicode handling.
'unidecode',
]
def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
"""
<Byte-compile one file.
Arguments (only fullname is required):
fullname: the file to byte-compile
ddir: if given, the directory name compiled in to the
byte-code file.
force: if 1, force compilation, even if timestamps are up-to-date
quiet: if 1, be quiet during compilation
"""
success = 1
name = os.path.basename(fullname)
if ddir is not None:
dfile = os.path.join(ddir, name)
else:
dfile = None
if rx is not None:
mo = rx.search(fullname)
if mo:
return success
if os.path.isfile(fullname):
tail = name[-3:]
if tail == '.py':
if not force:
try:
mtime = int(os.stat(fullname).st_mtime)
expect = struct.pack('<4sl', imp.get_magic(), mtime)
cfile = fullname + (__debug__ and 'c' or 'o')
with open(cfile, 'rb') as chandle:
actual = chandle.read(8)
if expect == actual:
return success
except IOError:
pass
if not quiet:
if isinstance(fullname, unicode):
print_name = fullname.encode('utf-8')
else:
print_name = fullname
print ('Compiling', print_name, '...')
try:
ok = py_compile.compile(fullname, None, dfile, True)
except py_compile.PyCompileError as err:
if quiet:
if isinstance(fullname, unicode):
print_name = fullname.encode('utf-8')
else:
print_name = fullname
print('Compiling', print_name, '...')
print(err.msg.encode('utf-8'))
success = 0
except IOError, e:
print('Sorry', e)
success = 0
else:
if ok == 0:
success = 0
return success
# Path the upstream code.
compileall.compile_file = compile_file
@task
def deps():
"""
Copy external dependencies.
"""
print('Installing dependencies to %s...' % (pave.path.build))
pave.pip(
command='install',
arguments=RUN_PACKAGES,
)