diff setup.py @ 40985:4277e20cfec4

rust-cpython: build and support for Python3 Defined Cargo features for Python3, making them overall simpler to use, hooked them in build and made mercurial.rustext importable. This is tested with Python 3.6.7. Differential Revision: https://phab.mercurial-scm.org/D5446
author Georges Racinet <gracinet@anybox.fr>
date Mon, 17 Dec 2018 15:05:52 +0100
parents f6987f654356
children 98ce494e104d
line wrap: on
line diff
--- a/setup.py	Tue Dec 18 00:54:32 2018 -0500
+++ b/setup.py	Mon Dec 17 15:05:52 2018 +0100
@@ -922,11 +922,13 @@
 
     rusttargetdir = os.path.join('rust', 'target', 'release')
 
-    def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
+    def __init__(self, mpath, sources, rustlibname, subcrate,
+                 py3_features=None, **kw):
         Extension.__init__(self, mpath, sources, **kw)
         if hgrustext is None:
             return
         srcdir = self.rustsrcdir = os.path.join('rust', subcrate)
+        self.py3_features = py3_features
 
         # adding Rust source and control files to depends so that the extension
         # gets rebuilt if they've changed
@@ -957,6 +959,9 @@
             env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
 
         cargocmd = ['cargo', 'build', '-vv', '--release']
+        if sys.version_info[0] == 3 and self.py3_features is not None:
+            cargocmd.extend(('--features', self.py3_features,
+                             '--no-default-features'))
         try:
             subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
         except OSError as exc:
@@ -1047,7 +1052,8 @@
 
 if hgrustext == 'cpython':
     extmodules.append(
-        RustStandaloneExtension('mercurial.rustext', 'hg-cpython', 'librusthg')
+        RustStandaloneExtension('mercurial.rustext', 'hg-cpython', 'librusthg',
+                                py3_features='python3')
     )