##// END OF EJS Templates
rust-cpython: build and support for Python3...
Georges Racinet -
r41021:4277e20c default
parent child Browse files
Show More
@@ -40,6 +40,10 b' if sys.version_info[0] >= 3:'
40 # zstd is already dual-version clean, don't try and mangle it
40 # zstd is already dual-version clean, don't try and mangle it
41 if fullname.startswith('mercurial.zstd'):
41 if fullname.startswith('mercurial.zstd'):
42 return None
42 return None
43 # rustext is built for the right python version,
44 # don't try and mangle it
45 if fullname.startswith('mercurial.rustext'):
46 return None
43 # pywatchman is already dual-version clean, don't try and mangle it
47 # pywatchman is already dual-version clean, don't try and mangle it
44 if fullname.startswith('hgext.fsmonitor.pywatchman'):
48 if fullname.startswith('hgext.fsmonitor.pywatchman'):
45 return None
49 return None
@@ -19,6 +19,7 b' dependencies = ['
19 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
19 "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
20 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
20 "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
21 "python27-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
21 "python27-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
22 "python3-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
22 ]
23 ]
23
24
24 [[package]]
25 [[package]]
@@ -8,9 +8,14 b" name='rusthg'"
8 crate-type = ["cdylib"]
8 crate-type = ["cdylib"]
9
9
10 [features]
10 [features]
11 default = ["python27", "python27-sys"]
11 default = ["python27"]
12
12
13 python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"]
13 python27 = ["cpython/python27-sys",
14 "cpython/extension-module-2-7",
15 "python27-sys",
16 ]
17
18 python3 = ["python3-sys", "cpython/python3-sys", "cpython/extension-module"]
14
19
15 [dependencies]
20 [dependencies]
16 hg-core = { path = "../hg-core" }
21 hg-core = { path = "../hg-core" }
@@ -922,11 +922,13 b' class RustExtension(Extension):'
922
922
923 rusttargetdir = os.path.join('rust', 'target', 'release')
923 rusttargetdir = os.path.join('rust', 'target', 'release')
924
924
925 def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
925 def __init__(self, mpath, sources, rustlibname, subcrate,
926 py3_features=None, **kw):
926 Extension.__init__(self, mpath, sources, **kw)
927 Extension.__init__(self, mpath, sources, **kw)
927 if hgrustext is None:
928 if hgrustext is None:
928 return
929 return
929 srcdir = self.rustsrcdir = os.path.join('rust', subcrate)
930 srcdir = self.rustsrcdir = os.path.join('rust', subcrate)
931 self.py3_features = py3_features
930
932
931 # adding Rust source and control files to depends so that the extension
933 # adding Rust source and control files to depends so that the extension
932 # gets rebuilt if they've changed
934 # gets rebuilt if they've changed
@@ -957,6 +959,9 b' class RustExtension(Extension):'
957 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
959 env['HOME'] = pwd.getpwuid(os.getuid()).pw_dir
958
960
959 cargocmd = ['cargo', 'build', '-vv', '--release']
961 cargocmd = ['cargo', 'build', '-vv', '--release']
962 if sys.version_info[0] == 3 and self.py3_features is not None:
963 cargocmd.extend(('--features', self.py3_features,
964 '--no-default-features'))
960 try:
965 try:
961 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
966 subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir)
962 except OSError as exc:
967 except OSError as exc:
@@ -1047,7 +1052,8 b' extmodules = ['
1047
1052
1048 if hgrustext == 'cpython':
1053 if hgrustext == 'cpython':
1049 extmodules.append(
1054 extmodules.append(
1050 RustStandaloneExtension('mercurial.rustext', 'hg-cpython', 'librusthg')
1055 RustStandaloneExtension('mercurial.rustext', 'hg-cpython', 'librusthg',
1056 py3_features='python3')
1051 )
1057 )
1052
1058
1053
1059
General Comments 0
You need to be logged in to leave comments. Login now