# HG changeset patch # User Georges Racinet <georges.raci...@octobus.net> # Date 1560506227 -3600 # Fri Jun 14 10:57:07 2019 +0100 # Node ID 559b63fe9ffeabb43c7d5322a53ad6defa718fb1 # Parent 87a34c76738492397abae40a27b6337f8be1b90d # EXP-Topic rust-build-platforms rust-cpython: management of shared libray suffix
Before this changeset, the shared library objects suffixes were both (rustc output and Python input) hardcoded to '.so', which is wrong for Python3 and non Linux targets. diff -r 87a34c767384 -r 559b63fe9ffe setup.py --- a/setup.py Mon May 27 16:55:46 2019 -0400 +++ b/setup.py Fri Jun 14 10:57:07 2019 +0100 @@ -32,6 +32,7 @@ ]) import sys, platform +import sysconfig if sys.version_info[0] >= 3: printf = eval('print') libdir_escape = 'unicode_escape' @@ -104,6 +105,12 @@ printf(error, file=sys.stderr) sys.exit(1) +if sys.version_info[0] >= 3: + DYLIB_SUFFIX = sysconfig.get_config_vars()['EXT_SUFFIX'] +else: + # deprecated in Python 3 + DYLIB_SUFFIX = sysconfig.get_config_vars()['SO'] + # Solaris Python packaging brain damage try: import hashlib @@ -1160,6 +1167,19 @@ for fname in fnames if os.path.splitext(fname)[1] == '.rs') + @staticmethod + def rustdylibsuffix(): + """Return the suffix for shared libraries produced by rustc. + + See also: https://doc.rust-lang.org/reference/linkage.html + """ + if sys.platform == 'darwin': + return '.dylib' + elif os.name == 'nt': + return '.dll' + else: + return '.so' + def rustbuild(self): env = os.environ.copy() if 'HGTEST_RESTOREENV' in env: @@ -1227,9 +1247,9 @@ self.rustbuild() target = [target_dir] target.extend(self.name.split('.')) - ext = '.so' # TODO Unix only - target[-1] += ext - shutil.copy2(os.path.join(self.rusttargetdir, self.dylibname + ext), + target[-1] += DYLIB_SUFFIX + shutil.copy2(os.path.join(self.rusttargetdir, + self.dylibname + self.rustdylibsuffix()), os.path.join(*target)) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel