Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e039425

Browse files
committed
Unfold some lines that were previously folded but don't need to be
now we're reindented. Remove files before renaming something to them -- for Windows. Change check for Python home directory so it works correct on Windows.
1 parent 541e783 commit e039425

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

Tools/freeze/freeze.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def main():
145145
prefix = sys.prefix
146146

147147
# determine whether -p points to the Python source tree
148-
ishome = os.path.exists(os.path.join(prefix, 'Include', 'pythonrun.h'))
148+
ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c'))
149149

150150
# locations derived from options
151151
version = sys.version[:3]
@@ -275,8 +275,8 @@ def main():
275275
outfp.close()
276276
if backup:
277277
if cmp.cmp(backup, frozen_c):
278-
sys.stderr.write('%s not changed, not written\n' %
279-
frozen_c)
278+
sys.stderr.write('%s not changed, not written\n' % frozen_c)
279+
os.unlink(frozen_c)
280280
os.rename(backup, frozen_c)
281281

282282
# windows gets different treatment
@@ -332,8 +332,8 @@ def main():
332332
infp.close()
333333
if backup:
334334
if cmp.cmp(backup, config_c):
335-
sys.stderr.write('%s not changed, not written\n' %
336-
config_c)
335+
sys.stderr.write('%s not changed, not written\n' % config_c)
336+
os.unlink(config_c)
337337
os.rename(backup, config_c)
338338

339339
cflags = defines + includes + ['$(OPT)']
@@ -351,6 +351,11 @@ def main():
351351
['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)']
352352

353353
backup = makefile + '~'
354+
if os.path.exists(makefile):
355+
try:
356+
os.unlink(backup)
357+
except os.error:
358+
pass
354359
try:
355360
os.rename(makefile, backup)
356361
except os.error:
@@ -364,8 +369,8 @@ def main():
364369
if not cmp.cmp(backup, makefile):
365370
print 'previous Makefile saved as', backup
366371
else:
367-
sys.stderr.write('%s not changed, not written\n' %
368-
makefile)
372+
sys.stderr.write('%s not changed, not written\n' % makefile)
373+
os.unlink(makefile)
369374
os.rename(backup, makefile)
370375

371376
# Done!

0 commit comments

Comments
 (0)