From patchwork Tue Jan 12 05:23:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,7,v2] setup: write mercurial/modulepolicy for pure installs From: timeless@mozdev.org X-Patchwork-Id: 12677 Message-Id: <17a8577c785046591d30.1452576189@waste.org> To: mercurial-devel@selenic.com Date: Mon, 11 Jan 2016 23:23:09 -0600 # HG changeset patch # User timeless # Date 1452574025 0 # Tue Jan 12 04:47:05 2016 +0000 # Node ID 17a8577c785046591d30f0b70ef6aff154c96720 # Parent dc89d0d3d9c1a422e0c2e2550d554357c54d7a2a setup: write mercurial/modulepolicy for pure installs This file tells the Mercurial loader to use Python libraries, which is what the user wanted when they ran setup --pure. diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -353,15 +353,22 @@ def copy_file(self, *args, **kwargs): src, dst = args[0:2] copied = False + inplace = False if './' + src != dst: dst, copied = build_py.copy_file(self, *args, **kwargs) + else: + inplace = True if dst.endswith('mercurial/__init__.py'): if self.distribution.pure: modulepolicy = 'py' else: modulepolicy = 'c' - if copied: + if inplace: + policy = os.path.join(os.path.dirname(dst), 'modulepolicy') + with open(policy, 'wb') as fh: + fh.write(modulepolicy) + elif copied: content = open(dst, 'rb').read() content = content.replace(b'@MODULELOADPOLICY@', modulepolicy.encode(libdir_escape))