[PATCH 4 of 7 v2] setup: short circuit copy_file for inplace
timeless
timeless at mozdev.org
Mon Jan 11 23:23:06 CST 2016
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1452572921 0
# Tue Jan 12 04:28:41 2016 +0000
# Node ID cffb330960bad95524d0d170fdc7aea009e5b01d
# Parent 475a0e5bf82fc9c943323fa7045a133dfbeb38e2
setup: short circuit copy_file for inplace
copy_file doesn't do any work if setup is called for `local`,
this saves a lot of thought for that noop.
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -344,18 +344,22 @@
'Mercurial but weren\'t found in %s' % h)
def copy_file(self, *args, **kwargs):
- dst, copied = build_py.copy_file(self, *args, **kwargs)
+ src, dst = args[0:2]
+ copied = False
+ if './' + src != dst:
+ dst, copied = build_py.copy_file(self, *args, **kwargs)
- if copied and dst.endswith('mercurial/__init__.py'):
+ if dst.endswith('mercurial/__init__.py'):
if self.distribution.pure:
modulepolicy = 'py'
else:
modulepolicy = 'c'
- content = open(dst, 'rb').read()
- content = content.replace(b'@MODULELOADPOLICY@',
- modulepolicy.encode(libdir_escape))
- with open(dst, 'wb') as fh:
- fh.write(content)
+ if copied:
+ content = open(dst, 'rb').read()
+ content = content.replace(b'@MODULELOADPOLICY@',
+ modulepolicy.encode(libdir_escape))
+ with open(dst, 'wb') as fh:
+ fh.write(content)
return dst, copied
More information about the Mercurial-devel
mailing list