From patchwork Tue Jan 12 05:23:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5,of,7,v2] mercurial: check mercurial/modulepolicy for modulepolicy From: timeless@mozdev.org X-Patchwork-Id: 12675 Message-Id: <21b17c69ea254cceefc4.1452576187@waste.org> To: mercurial-devel@selenic.com Date: Mon, 11 Jan 2016 23:23:07 -0600 # HG changeset patch # User timeless # Date 1452574998 0 # Tue Jan 12 05:03:18 2016 +0000 # Node ID 21b17c69ea254cceefc474baabedd5a777278c8c # Parent cffb330960bad95524d0d170fdc7aea009e5b01d mercurial: check mercurial/modulepolicy for modulepolicy On local pure systems, setup doesn't rewrite mercurial/__init__.py, because the file is managed by Mercurial... In order to let such systems work, we allow for a file: mercurial/modulepolicy to determine the policy. A later patch will have setup.py write to this file. diff --git a/mercurial/__init__.py b/mercurial/__init__.py --- a/mercurial/__init__.py +++ b/mercurial/__init__.py @@ -23,7 +23,15 @@ # By default, require the C extensions for performance reasons. if modulepolicy == '@' 'MODULELOADPOLICY' '@': - modulepolicy = 'c' + try: + policyfile = os.path.join(os.path.dirname(__file__), 'modulepolicy') + fp = open(policyfile, 'rb') + r = fp.read() + fp.close() + if r: + modulepolicy = r.split("\n")[0] + except IOError: + modulepolicy = 'c' # PyPy doesn't load C extensions. #