Skip to content

Commit 8aa1c64

Browse files
author
y-p
committed
Revert "BLD: ci/print_versions.py, LC_ALL/LANG should default None"
This reverts commit b9ca0ed.
1 parent 1494b2b commit 8aa1c64

File tree

3 files changed

+59
-25
lines changed

3 files changed

+59
-25
lines changed

ci/print_versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import os
99
(sysname, nodename, release, version, machine) = os.uname()
1010
print("OS: %s %s %s %s" % (sysname, release, version,machine))
11-
print("LC_ALL: %s" % os.environ.get('LC_ALL',"None"))
12-
print("LANG: %s" % os.environ.get('LANG',"None"))
11+
print("LC_ALL: %s" % os.environ['LC_ALL'])
12+
print("LANG: %s" % os.environ['LANG'])
1313
except:
1414
pass
1515

scripts/use_build_cache.py

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,39 @@
1212
- The .c files resulting from cythonizing pyx/d files
1313
- 2to3 refactoring results (when run under python3)
1414
15-
Tested on all released back to 0.7.0.
15+
Tested on releases back to 0.7.0.
1616
1717
"""
18+
import argparse
19+
argparser = argparse.ArgumentParser(description="""
20+
'Program description.
21+
""".strip())
22+
23+
argparser.add_argument('-f', '--force-overwrite',
24+
default=False,
25+
help='Setting this will overwrite any existing cache results for the current commit',
26+
action='store_true')
27+
argparser.add_argument('-d', '--debug',
28+
default=False,
29+
help='Report cache hits/misses',
30+
action='store_true')
31+
32+
args = argparser.parse_args()
33+
34+
#print args.accumulate(args.integers)
35+
1836
shim="""
1937
import os
2038
import sys
2139
import shutil
2240
import warnings
41+
import re
42+
"""
43+
44+
shim += ("BC_FORCE_OVERWRITE = %s\n" % args.force_overwrite)
45+
shim += ("BC_DEBUG = %s\n" % args.debug)
2346

47+
shim += """
2448
try:
2549
if not ("develop" in sys.argv) and not ("install" in sys.argv):
2650
1/0
@@ -34,6 +58,7 @@
3458
if os.path.isdir(BUILD_CACHE_DIR):
3559
print("--------------------------------------------------------")
3660
print("BUILD CACHE ACTIVATED (V2). be careful, this is experimental.")
61+
print("BUILD_CACHE_DIR: " + BUILD_CACHE_DIR )
3762
print("--------------------------------------------------------")
3863
else:
3964
BUILD_CACHE_DIR = None
@@ -65,33 +90,41 @@
6590
h = sha1(open(f,"rb").read()).hexdigest()
6691
except IOError:
6792
to_process[h] = f
68-
if h in orig_hashes:
93+
if h in orig_hashes and not BC_FORCE_OVERWRITE:
6994
src = os.path.join(BUILD_CACHE_DIR,orig_hashes[h])
70-
# print("cache hit %s,%s" % (f,h))
95+
if BC_DEBUG:
96+
print("2to3 cache hit %s,%s" % (f,h))
7197
shutil.copyfile(src,f)
7298
elif h not in post_hashes:
7399
74100
# we're not in a dev dir with already processed files
75-
# print("cache miss %s,%s" % (f,h))
76-
# print("will process " + f)
101+
if BC_DEBUG:
102+
print("2to3 cache miss %s,%s" % (f,h))
103+
print("2to3 will process " + f)
77104
to_process[h] = f
78105
79106
avail_fixes = set(refactor.get_fixers_from_package("lib2to3.fixes"))
80107
avail_fixes.discard('lib2to3.fixes.fix_next')
81108
t=refactor.RefactoringTool(avail_fixes)
82-
t.refactor(to_process.values(),True)
83-
print("2to3 done refactoring.")
84-
for orig_h in to_process:
85-
f = to_process[orig_h]
86-
post_h = sha1(open(f,"rb").read()).hexdigest()
87-
cached_fname = orig_h + "-" + post_h + "-" + pyver
88-
# print("cache put %s,%s in %s" % (f,h,cached_fname))
89-
shutil.copyfile(f,os.path.join(BUILD_CACHE_DIR,cached_fname))
109+
print("Starting 2to3 refactoring...")
110+
for f in to_process.values():
111+
if BC_DEBUG:
112+
print("2to3 on %s" % f)
113+
try:
114+
t.refactor([f],True)
115+
post_h = sha1(open(f, "rb").read()).hexdigest()
116+
cached_fname = f + "-" + post_h + "-" + pyver
117+
if BC_DEBUG:
118+
print("cache put %s,%s in %s" % (f, h, cached_fname))
119+
shutil.copyfile(f, os.path.join(BUILD_CACHE_DIR, cached_fname))
90120
91-
except:
92-
BUILD_CACHE_DIR = None
121+
except:
122+
pass
123+
print("2to3 done refactoring.")
93124
94-
print("BUILD_CACHE_DIR: " + str(BUILD_CACHE_DIR) )
125+
except Exception as e:
126+
print( "Exception: " + str(e))
127+
BUILD_CACHE_DIR = None
95128
96129
class CompilationCacheMixin(object):
97130
def __init__(self, *args, **kwds):
@@ -102,9 +135,10 @@ def __init__(self, *args, **kwds):
102135
103136
def _copy_from_cache(self, hash, target):
104137
src = os.path.join(self.cache_dir, hash)
105-
if os.path.exists(src):
106-
# print("Cache HIT: asked to copy file %s in %s" %
107-
# (src,os.path.abspath(target)))
138+
if os.path.exists(src) and not BC_FORCE_OVERWRITE:
139+
if BC_DEBUG:
140+
print("Cache HIT: asked to copy file %s in %s" %
141+
(src,os.path.abspath(target)))
108142
s = "."
109143
for d in target.split(os.path.sep)[:-1]:
110144
s = os.path.join(s, d)
@@ -118,7 +152,8 @@ def _copy_from_cache(self, hash, target):
118152
119153
def _put_to_cache(self, hash, src):
120154
target = os.path.join(self.cache_dir, hash)
121-
# print( "Cache miss: asked to copy file from %s to %s" % (src,target))
155+
if BC_DEBUG:
156+
print( "Cache miss: asked to copy file from %s to %s" % (src,target))
122157
s = "."
123158
for d in target.split(os.path.sep)[:-1]:
124159
s = os.path.join(s, d)
@@ -263,7 +298,7 @@ def main():
263298
SEP="\nsetup("
264299
before,after = s.split(SEP)
265300
with open(opj(opd(__file__),"..","setup.py"),"wb") as f:
266-
f.write(before + shim + SEP + after)
301+
f.write((before + shim + SEP + after).encode('ascii'))
267302
print("""
268303
setup.py was rewritten to use a build cache.
269304
Make sure you've put the following in your .bashrc:
@@ -282,7 +317,6 @@ def main():
282317
283318
""")
284319

285-
286320
if __name__ == '__main__':
287321
import sys
288322
sys.exit(main())

vb_suite/test_perf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def print_report(df,h_head=None,h_msg="",h_baseline=None,b_msg=""):
356356
if not args.quiet:
357357
prprint(s)
358358

359-
if args.stats:
359+
if args.stats and args.quiet:
360360
prprint(stats_footer)
361361

362362
prprint("Results were also written to the logfile at '%s'" %

0 commit comments

Comments
 (0)