comparison setup.py @ 44466:79ac59d3f73d

setup-rust: remove the legacy 'direct-ffi' variant This variant have been abandoned for a while. Keeping it around just get people confused.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 06 Mar 2020 16:49:46 +0100
parents 9d2b2df2c2ba
children ad718271a9eb
comparison
equal deleted inserted replaced
44465:75ada5fe9b62 44466:79ac59d3f73d
1 # 1 #
2 # This is the mercurial setup script. 2 # This is the mercurial setup script.
3 # 3 #
4 # 'python setup.py install', or 4 # 'python setup.py install', or
5 # 'python setup.py --help' for more options 5 # 'python setup.py --help' for more options
6 from __future__ import print_function
6 7
7 import os 8 import os
8 9
9 # Mercurial will never work on Python 3 before 3.5 due to a lack 10 # Mercurial will never work on Python 3 before 3.5 due to a lack
10 # of % formatting on bytestrings, and can't work on 3.6.0 or 3.6.1 11 # of % formatting on bytestrings, and can't work on 3.6.0 or 3.6.1
139 140
140 hgrustext = os.environ.get('HGWITHRUSTEXT') 141 hgrustext = os.environ.get('HGWITHRUSTEXT')
141 # TODO record it for proper rebuild upon changes 142 # TODO record it for proper rebuild upon changes
142 # (see mercurial/__modulepolicy__.py) 143 # (see mercurial/__modulepolicy__.py)
143 if hgrustext != 'cpython' and hgrustext is not None: 144 if hgrustext != 'cpython' and hgrustext is not None:
144 hgrustext = 'direct-ffi' 145 if hgrustext:
146 print('unkown HGWITHRUSTEXT value: %s' % hgrustext, file=sys.stderr)
147 hgrustext = None
145 148
146 import ctypes 149 import ctypes
147 import errno 150 import errno
148 import stat, subprocess, time 151 import stat, subprocess, time
149 import re 152 import re
541 ] 544 ]
542 545
543 # Build Rust standalon extensions if it'll be used 546 # Build Rust standalon extensions if it'll be used
544 # and its build is not explictely disabled (for external build 547 # and its build is not explictely disabled (for external build
545 # as Linux distributions would do) 548 # as Linux distributions would do)
546 if self.distribution.rust and self.rust and hgrustext != 'direct-ffi': 549 if self.distribution.rust and self.rust:
547 for rustext in ruststandalones: 550 for rustext in ruststandalones:
548 rustext.build('' if self.inplace else self.build_lib) 551 rustext.build('' if self.inplace else self.build_lib)
549 552
550 return build_ext.build_extensions(self) 553 return build_ext.build_extensions(self)
551 554
1389 "command: %r, environment: %r" 1392 "command: %r, environment: %r"
1390 % (self.rustsrcdir, cargocmd, env) 1393 % (self.rustsrcdir, cargocmd, env)
1391 ) 1394 )
1392 1395
1393 1396
1394 class RustEnhancedExtension(RustExtension):
1395 """A C Extension, conditionally enhanced with Rust code.
1396
1397 If the HGWITHRUSTEXT environment variable is set to something else
1398 than 'cpython', the Rust sources get compiled and linked within
1399 the C target shared library object.
1400 """
1401
1402 def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
1403 RustExtension.__init__(
1404 self, mpath, sources, rustlibname, subcrate, **kw
1405 )
1406 if hgrustext != 'direct-ffi':
1407 return
1408 self.extra_compile_args.append('-DWITH_RUST')
1409 self.libraries.append(rustlibname)
1410 self.library_dirs.append(self.rusttargetdir)
1411
1412 def rustbuild(self):
1413 if hgrustext == 'direct-ffi':
1414 RustExtension.rustbuild(self)
1415
1416
1417 class RustStandaloneExtension(RustExtension): 1397 class RustStandaloneExtension(RustExtension):
1418 def __init__(self, pydottedname, rustcrate, dylibname, **kw): 1398 def __init__(self, pydottedname, rustcrate, dylibname, **kw):
1419 RustExtension.__init__( 1399 RustExtension.__init__(
1420 self, pydottedname, [], dylibname, rustcrate, **kw 1400 self, pydottedname, [], dylibname, rustcrate, **kw
1421 ) 1401 )
1451 'mercurial.cext.mpatch', 1431 'mercurial.cext.mpatch',
1452 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'], 1432 ['mercurial/mpatch.c', 'mercurial/cext/mpatch.c'],
1453 include_dirs=common_include_dirs, 1433 include_dirs=common_include_dirs,
1454 depends=common_depends, 1434 depends=common_depends,
1455 ), 1435 ),
1456 RustEnhancedExtension( 1436 Extension(
1457 'mercurial.cext.parsers', 1437 'mercurial.cext.parsers',
1458 [ 1438 [
1459 'mercurial/cext/charencode.c', 1439 'mercurial/cext/charencode.c',
1460 'mercurial/cext/dirs.c', 1440 'mercurial/cext/dirs.c',
1461 'mercurial/cext/manifest.c', 1441 'mercurial/cext/manifest.c',
1462 'mercurial/cext/parsers.c', 1442 'mercurial/cext/parsers.c',
1463 'mercurial/cext/pathencode.c', 1443 'mercurial/cext/pathencode.c',
1464 'mercurial/cext/revlog.c', 1444 'mercurial/cext/revlog.c',
1465 ], 1445 ],
1466 'hgdirectffi',
1467 'hg-direct-ffi',
1468 include_dirs=common_include_dirs, 1446 include_dirs=common_include_dirs,
1469 depends=common_depends 1447 depends=common_depends
1470 + [ 1448 + ['mercurial/cext/charencode.h', 'mercurial/cext/revlog.h',],
1471 'mercurial/cext/charencode.h',
1472 'mercurial/cext/revlog.h',
1473 'rust/hg-core/src/ancestors.rs',
1474 'rust/hg-core/src/lib.rs',
1475 ],
1476 ), 1449 ),
1477 Extension( 1450 Extension(
1478 'mercurial.cext.osutil', 1451 'mercurial.cext.osutil',
1479 ['mercurial/cext/osutil.c'], 1452 ['mercurial/cext/osutil.c'],
1480 include_dirs=common_include_dirs, 1453 include_dirs=common_include_dirs,