From patchwork Fri Oct 8 09:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11618: rust: Make the hg-cpython crate default to Python 3 From: phabricator X-Patchwork-Id: 49942 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 8 Oct 2021 09:59:51 +0000 SimonSapin created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This default is used when running `cargo` manually such as for `cargo test`. `setup.py` and `Makefile` both configure the Python major version explicitly. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11618 AFFECTED FILES rust/hg-cpython/Cargo.toml setup.py CHANGE DETAILS To: SimonSapin, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1428,12 +1428,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 @@ -1481,9 +1478,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: @@ -1605,7 +1604,9 @@ extra_compile_args=common_cflags, ), RustStandaloneExtension( - 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3' + 'mercurial.rustext', + 'hg-cpython', + 'librusthg', ), ] diff --git a/rust/hg-cpython/Cargo.toml b/rust/hg-cpython/Cargo.toml --- a/rust/hg-cpython/Cargo.toml +++ b/rust/hg-cpython/Cargo.toml @@ -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"]