Skip to content

Commit b9ca0ed

Browse files
author
y-p
committed
BLD: ci/print_versions.py, LC_ALL/LANG should default None
1 parent 30f1814 commit b9ca0ed

File tree

3 files changed

+25
-59
lines changed

3 files changed

+25
-59
lines changed

ci/print_versions.py

+2-2
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['LC_ALL'])
12-
print("LANG: %s" % os.environ['LANG'])
11+
print("LC_ALL: %s" % os.environ.get('LC_ALL',"None"))
12+
print("LANG: %s" % os.environ.get('LANG',"None"))
1313
except:
1414
pass
1515

scripts/use_build_cache.py

+22-56
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,15 @@
1212
- The .c files resulting from cythonizing pyx/d files
1313
- 2to3 refactoring results (when run under python3)
1414
15-
Tested on releases back to 0.7.0.
15+
Tested on all released 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-
3618
shim="""
3719
import os
3820
import sys
3921
import shutil
4022
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)
4623
47-
shim += """
4824
try:
4925
if not ("develop" in sys.argv) and not ("install" in sys.argv):
5026
1/0
@@ -58,7 +34,6 @@
5834
if os.path.isdir(BUILD_CACHE_DIR):
5935
print("--------------------------------------------------------")
6036
print("BUILD CACHE ACTIVATED (V2). be careful, this is experimental.")
61-
print("BUILD_CACHE_DIR: " + BUILD_CACHE_DIR )
6237
print("--------------------------------------------------------")
6338
else:
6439
BUILD_CACHE_DIR = None
@@ -90,41 +65,33 @@
9065
h = sha1(open(f,"rb").read()).hexdigest()
9166
except IOError:
9267
to_process[h] = f
93-
if h in orig_hashes and not BC_FORCE_OVERWRITE:
68+
if h in orig_hashes:
9469
src = os.path.join(BUILD_CACHE_DIR,orig_hashes[h])
95-
if BC_DEBUG:
96-
print("2to3 cache hit %s,%s" % (f,h))
70+
# print("cache hit %s,%s" % (f,h))
9771
shutil.copyfile(src,f)
9872
elif h not in post_hashes:
9973
10074
# we're not in a dev dir with already processed files
101-
if BC_DEBUG:
102-
print("2to3 cache miss %s,%s" % (f,h))
103-
print("2to3 will process " + f)
75+
# print("cache miss %s,%s" % (f,h))
76+
# print("will process " + f)
10477
to_process[h] = f
10578
10679
avail_fixes = set(refactor.get_fixers_from_package("lib2to3.fixes"))
10780
avail_fixes.discard('lib2to3.fixes.fix_next')
10881
t=refactor.RefactoringTool(avail_fixes)
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))
120-
121-
except:
122-
pass
82+
t.refactor(to_process.values(),True)
12383
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))
90+
91+
except:
92+
BUILD_CACHE_DIR = None
12493
125-
except Exception as e:
126-
print( "Exception: " + str(e))
127-
BUILD_CACHE_DIR = None
94+
print("BUILD_CACHE_DIR: " + str(BUILD_CACHE_DIR) )
12895
12996
class CompilationCacheMixin(object):
13097
def __init__(self, *args, **kwds):
@@ -135,10 +102,9 @@ def __init__(self, *args, **kwds):
135102
136103
def _copy_from_cache(self, hash, target):
137104
src = os.path.join(self.cache_dir, hash)
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)))
105+
if os.path.exists(src):
106+
# print("Cache HIT: asked to copy file %s in %s" %
107+
# (src,os.path.abspath(target)))
142108
s = "."
143109
for d in target.split(os.path.sep)[:-1]:
144110
s = os.path.join(s, d)
@@ -152,8 +118,7 @@ def _copy_from_cache(self, hash, target):
152118
153119
def _put_to_cache(self, hash, src):
154120
target = os.path.join(self.cache_dir, hash)
155-
if BC_DEBUG:
156-
print( "Cache miss: asked to copy file from %s to %s" % (src,target))
121+
# print( "Cache miss: asked to copy file from %s to %s" % (src,target))
157122
s = "."
158123
for d in target.split(os.path.sep)[:-1]:
159124
s = os.path.join(s, d)
@@ -298,7 +263,7 @@ def main():
298263
SEP="\nsetup("
299264
before,after = s.split(SEP)
300265
with open(opj(opd(__file__),"..","setup.py"),"wb") as f:
301-
f.write((before + shim + SEP + after).encode('ascii'))
266+
f.write(before + shim + SEP + after)
302267
print("""
303268
setup.py was rewritten to use a build cache.
304269
Make sure you've put the following in your .bashrc:
@@ -317,6 +282,7 @@ def main():
317282
318283
""")
319284

285+
320286
if __name__ == '__main__':
321287
import sys
322288
sys.exit(main())

vb_suite/test_perf.py

+1-1
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 and args.quiet:
359+
if args.stats:
360360
prprint(stats_footer)
361361

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

0 commit comments

Comments
 (0)