# HG changeset patch # User Simon Sapin # Date 1633683963 -7200 # Node ID 01c3dd208c75a6d2b08f2f0c55340dd2a3ddaba3 # Parent c95f6c2d1f4e53a06157645195dfe8e34b0e42c5 rust: Make the hg-cpython crate default to Python 3 This default is used when running `cargo` manually such as for `cargo test`. `setup.py` and `Makefile` both configure the Python major version explicitly. Differential Revision: https://phab.mercurial-scm.org/D11618 diff -r c95f6c2d1f4e -r 01c3dd208c75 rust/hg-cpython/Cargo.toml --- a/rust/hg-cpython/Cargo.toml Sun Oct 03 20:11:42 2021 -0400 +++ b/rust/hg-cpython/Cargo.toml Fri Oct 08 11:06:03 2021 +0200 @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [features] -default = ["python27"] +default = ["python3"] # Features to build an extension module: python27 = ["cpython/python27-sys", "cpython/extension-module-2-7"] diff -r c95f6c2d1f4e -r 01c3dd208c75 setup.py --- a/setup.py Sun Oct 03 20:11:42 2021 -0400 +++ b/setup.py Fri Oct 08 11:06:03 2021 +0200 @@ -1398,12 +1398,9 @@ rusttargetdir = os.path.join('rust', 'target', 'release') - def __init__( - self, mpath, sources, rustlibname, subcrate, py3_features=None, **kw - ): + def __init__(self, mpath, sources, rustlibname, subcrate, **kw): Extension.__init__(self, mpath, sources, **kw) 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 @@ -1451,9 +1448,11 @@ feature_flags = [] - if sys.version_info[0] == 3 and self.py3_features is not None: - feature_flags.append(self.py3_features) - cargocmd.append('--no-default-features') + cargocmd.append('--no-default-features') + if sys.version_info[0] == 2: + feature_flags.append('python27') + elif sys.version_info[0] == 3: + feature_flags.append('python3') rust_features = env.get("HG_RUST_FEATURES") if rust_features: @@ -1575,7 +1574,9 @@ extra_compile_args=common_cflags, ), RustStandaloneExtension( - 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3' + 'mercurial.rustext', + 'hg-cpython', + 'librusthg', ), ]