Mercurial > hg
comparison setup.py @ 48182:01c3dd208c75
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
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 08 Oct 2021 11:06:03 +0200 |
parents | f78d8b8c46d7 |
children | 2ce31dbde4b1 |
comparison
equal
deleted
inserted
replaced
48181:c95f6c2d1f4e | 48182:01c3dd208c75 |
---|---|
1396 class RustExtension(Extension): | 1396 class RustExtension(Extension): |
1397 """Base classes for concrete Rust Extension classes.""" | 1397 """Base classes for concrete Rust Extension classes.""" |
1398 | 1398 |
1399 rusttargetdir = os.path.join('rust', 'target', 'release') | 1399 rusttargetdir = os.path.join('rust', 'target', 'release') |
1400 | 1400 |
1401 def __init__( | 1401 def __init__(self, mpath, sources, rustlibname, subcrate, **kw): |
1402 self, mpath, sources, rustlibname, subcrate, py3_features=None, **kw | |
1403 ): | |
1404 Extension.__init__(self, mpath, sources, **kw) | 1402 Extension.__init__(self, mpath, sources, **kw) |
1405 srcdir = self.rustsrcdir = os.path.join('rust', subcrate) | 1403 srcdir = self.rustsrcdir = os.path.join('rust', subcrate) |
1406 self.py3_features = py3_features | |
1407 | 1404 |
1408 # adding Rust source and control files to depends so that the extension | 1405 # adding Rust source and control files to depends so that the extension |
1409 # gets rebuilt if they've changed | 1406 # gets rebuilt if they've changed |
1410 self.depends.append(os.path.join(srcdir, 'Cargo.toml')) | 1407 self.depends.append(os.path.join(srcdir, 'Cargo.toml')) |
1411 cargo_lock = os.path.join(srcdir, 'Cargo.lock') | 1408 cargo_lock = os.path.join(srcdir, 'Cargo.lock') |
1449 | 1446 |
1450 cargocmd = ['cargo', 'rustc', '--release'] | 1447 cargocmd = ['cargo', 'rustc', '--release'] |
1451 | 1448 |
1452 feature_flags = [] | 1449 feature_flags = [] |
1453 | 1450 |
1454 if sys.version_info[0] == 3 and self.py3_features is not None: | 1451 cargocmd.append('--no-default-features') |
1455 feature_flags.append(self.py3_features) | 1452 if sys.version_info[0] == 2: |
1456 cargocmd.append('--no-default-features') | 1453 feature_flags.append('python27') |
1454 elif sys.version_info[0] == 3: | |
1455 feature_flags.append('python3') | |
1457 | 1456 |
1458 rust_features = env.get("HG_RUST_FEATURES") | 1457 rust_features = env.get("HG_RUST_FEATURES") |
1459 if rust_features: | 1458 if rust_features: |
1460 feature_flags.append(rust_features) | 1459 feature_flags.append(rust_features) |
1461 | 1460 |
1573 'hgext.fsmonitor.pywatchman.bser', | 1572 'hgext.fsmonitor.pywatchman.bser', |
1574 ['hgext/fsmonitor/pywatchman/bser.c'], | 1573 ['hgext/fsmonitor/pywatchman/bser.c'], |
1575 extra_compile_args=common_cflags, | 1574 extra_compile_args=common_cflags, |
1576 ), | 1575 ), |
1577 RustStandaloneExtension( | 1576 RustStandaloneExtension( |
1578 'mercurial.rustext', 'hg-cpython', 'librusthg', py3_features='python3' | 1577 'mercurial.rustext', |
1578 'hg-cpython', | |
1579 'librusthg', | |
1579 ), | 1580 ), |
1580 ] | 1581 ] |
1581 | 1582 |
1582 | 1583 |
1583 sys.path.insert(0, 'contrib/python-zstandard') | 1584 sys.path.insert(0, 'contrib/python-zstandard') |