129 from distutils.errors import ( |
129 from distutils.errors import ( |
130 CCompilerError, |
130 CCompilerError, |
131 DistutilsError, |
131 DistutilsError, |
132 DistutilsExecError, |
132 DistutilsExecError, |
133 ) |
133 ) |
134 from distutils.sysconfig import get_python_inc, get_config_var |
134 from distutils.sysconfig import get_python_inc |
135 from distutils.version import StrictVersion |
|
136 |
|
137 # Explain to distutils.StrictVersion how our release candidates are versioned |
|
138 StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') |
|
139 |
135 |
140 |
136 |
141 def write_if_changed(path, content): |
137 def write_if_changed(path, content): |
142 """Write content to a file iff the content hasn't changed.""" |
138 """Write content to a file iff the content hasn't changed.""" |
143 if os.path.exists(path): |
139 if os.path.exists(path): |
1502 def build(self, target_dir): |
1498 def build(self, target_dir): |
1503 self.rustbuild() |
1499 self.rustbuild() |
1504 target = [target_dir] |
1500 target = [target_dir] |
1505 target.extend(self.name.split('.')) |
1501 target.extend(self.name.split('.')) |
1506 target[-1] += DYLIB_SUFFIX |
1502 target[-1] += DYLIB_SUFFIX |
|
1503 target = os.path.join(*target) |
|
1504 os.makedirs(os.path.dirname(target), exist_ok=True) |
1507 shutil.copy2( |
1505 shutil.copy2( |
1508 os.path.join( |
1506 os.path.join( |
1509 self.rusttargetdir, self.dylibname + self.rustdylibsuffix() |
1507 self.rusttargetdir, self.dylibname + self.rustdylibsuffix() |
1510 ), |
1508 ), |
1511 os.path.join(*target), |
1509 target, |
1512 ) |
1510 ) |
1513 |
1511 |
1514 |
1512 |
1515 extmodules = [ |
1513 extmodules = [ |
1516 Extension( |
1514 Extension( |
1735 |
1737 |
1736 if os.name == 'nt': |
1738 if os.name == 'nt': |
1737 # Windows binary file versions for exe/dll files must have the |
1739 # Windows binary file versions for exe/dll files must have the |
1738 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 |
1740 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 |
1739 setupversion = setupversion.split(r'+', 1)[0] |
1741 setupversion = setupversion.split(r'+', 1)[0] |
1740 |
|
1741 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): |
|
1742 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[1].splitlines() |
|
1743 if version: |
|
1744 version = version[0].decode('utf-8') |
|
1745 xcode4 = version.startswith('Xcode') and StrictVersion( |
|
1746 version.split()[1] |
|
1747 ) >= StrictVersion('4.0') |
|
1748 xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None |
|
1749 else: |
|
1750 # xcodebuild returns empty on OS X Lion with XCode 4.3 not |
|
1751 # installed, but instead with only command-line tools. Assume |
|
1752 # that only happens on >= Lion, thus no PPC support. |
|
1753 xcode4 = True |
|
1754 xcode51 = False |
|
1755 |
|
1756 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in |
|
1757 # distutils.sysconfig |
|
1758 if xcode4: |
|
1759 os.environ['ARCHFLAGS'] = '' |
|
1760 |
|
1761 # XCode 5.1 changes clang such that it now fails to compile if the |
|
1762 # -mno-fused-madd flag is passed, but the version of Python shipped with |
|
1763 # OS X 10.9 Mavericks includes this flag. This causes problems in all |
|
1764 # C extension modules, and a bug has been filed upstream at |
|
1765 # http://bugs.python.org/issue21244. We also need to patch this here |
|
1766 # so Mercurial can continue to compile in the meantime. |
|
1767 if xcode51: |
|
1768 cflags = get_config_var('CFLAGS') |
|
1769 if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None: |
|
1770 os.environ['CFLAGS'] = ( |
|
1771 os.environ.get('CFLAGS', '') + ' -Qunused-arguments' |
|
1772 ) |
|
1773 |
1742 |
1774 setup( |
1743 setup( |
1775 name='mercurial', |
1744 name='mercurial', |
1776 version=setupversion, |
1745 version=setupversion, |
1777 author='Olivia Mackall and many others', |
1746 author='Olivia Mackall and many others', |