Patchwork setup: do not overwrite local __modulepolicy__.py on out-of-source build

login
register
mail settings
Submitter Yuya Nishihara
Date June 3, 2017, 2:28 p.m.
Message ID <838ebaa0d8d704c03b46.1496500119@mimosa>
Download mbox | patch
Permalink /patch/21155/
State Accepted
Headers show

Comments

Yuya Nishihara - June 3, 2017, 2:28 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1496466352 -32400
#      Sat Jun 03 14:05:52 2017 +0900
# Node ID 838ebaa0d8d704c03b461d3e4bd510a427578afd
# Parent  783394c0c97807e83daad9da561179bd0719e159
setup: do not overwrite local __modulepolicy__.py on out-of-source build

Since the default policy is selected depending on setup options, "make install"
shouldn't overwrite in-source __modulepolicy__.py generated by "make local".
Augie Fackler - June 3, 2017, 8:34 p.m.
On Sat, Jun 03, 2017 at 11:28:39PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1496466352 -32400
> #      Sat Jun 03 14:05:52 2017 +0900
> # Node ID 838ebaa0d8d704c03b461d3e4bd510a427578afd
> # Parent  783394c0c97807e83daad9da561179bd0719e159
> setup: do not overwrite local __modulepolicy__.py on out-of-source build

queued, thanks

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -371,6 +371,9 @@  class hgbuildpy(build_py):
                                  'Mercurial but weren\'t found in %s' % h)
 
     def run(self):
+        basepath = os.path.join(self.build_lib, 'mercurial')
+        self.mkpath(basepath)
+
         if self.distribution.pure:
             modulepolicy = 'py'
         elif self.build_lib == '.':
@@ -378,7 +381,7 @@  class hgbuildpy(build_py):
             modulepolicy = 'allow'
         else:
             modulepolicy = 'c'
-        with open("mercurial/__modulepolicy__.py", "w") as f:
+        with open(os.path.join(basepath, '__modulepolicy__.py'), "w") as f:
             f.write('# this file is autogenerated by setup.py\n')
             f.write('modulepolicy = b"%s"\n' % modulepolicy)