[PATCH 3 of 3] setup: build exewrapper with Unicode support on py3

Matt Harbison mharbison72 at gmail.com
Fri Oct 19 18:56:48 EDT 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1539988482 14400
#      Fri Oct 19 18:34:42 2018 -0400
# Node ID b3ff9d946a3b919f4a96c5637efed828a89c343a
# Parent  b5a4766f29dd828a64a156d3d9e275b4bbe649a2
setup: build exewrapper with Unicode support on py3

I didn't see a compiler switch documented anywhere, but I diffed the command
line for full VC++ project when toggling between MBCS and Unicode.  This is all
they do.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -631,8 +631,14 @@ class buildhgexe(build_ext):
         with open('mercurial/hgpythonlib.h', 'wb') as f:
             f.write(b'/* this file is autogenerated by setup.py */\n')
             f.write(b'#define HGPYTHONLIB "%s"\n' % pythonlib)
+
+        macros = None
+        if sys.version_info[0] >= 3:
+            macros = [('_UNICODE', None), ('UNICODE', None)]
+
         objects = self.compiler.compile(['mercurial/exewrapper.c'],
-                                         output_dir=self.build_temp)
+                                         output_dir=self.build_temp,
+                                         macros=macros)
         dir = os.path.dirname(self.get_ext_fullpath('dummy'))
         self.hgtarget = os.path.join(dir, 'hg')
         self.compiler.link_executable(objects, self.hgtarget,


More information about the Mercurial-devel mailing list