[PATCH 3 of 6] setup: note that copy_file does nothing for local installs

timeless timeless at mozdev.org
Tue Mar 8 00:33:21 EST 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1457384519 0
#      Mon Mar 07 21:01:59 2016 +0000
# Node ID 87c23b43ccb5387c236ea1624822dd54392bc73d
# Parent  6c3d93079648b1993ef0d14488634b82665f7a30
setup: note that copy_file does nothing for local installs

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -344,19 +344,22 @@
                                  'Mercurial but weren\'t found in %s' % h)
 
     def copy_file(self, *args, **kwargs):
+        # copy_file takes a long time to do nothing (returning copied=0)
+        # for local installs.
         dst, copied = build_py.copy_file(self, *args, **kwargs)
 
-        if (copied and dst.endswith('__init__.py') and
+        if (dst.endswith('__init__.py') and
             os.path.split(dst)[-2].endswith('mercurial')):
             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