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

login
register
mail settings
Submitter Matt Harbison
Date Oct. 19, 2018, 10:56 p.m.
Message ID <b3ff9d946a3b919f4a96.1539989808@mharbison-pc.attotech.com>
Download mbox | patch
Permalink /patch/36202/
State New
Headers show

Comments

Matt Harbison - Oct. 19, 2018, 10:56 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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.
Augie Fackler - Oct. 22, 2018, 3:40 p.m.
On Fri, Oct 19, 2018 at 06:56:48PM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@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

queued, thanks

Patch

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,