Mercurial > public > mercurial-scm > hg
comparison setup.py @ 49879:dd804d83822c
setup: drop legacy osx compiler tuning to enable universal builds
This was triggering deprecation warnings about migrating to `packaging.version`
from `distutils` Version classes with `make local`. But rather than migrate
that code, let's just get rid of some ~10-12 year old workarounds. As a bonus,
the cext libraries that are built are now universal binaries containing x86_64
and arm64 images (at least when built on macOS 11.4 with Xcode 12.5 and the
universal version of Python 3.9.13).
Several things to note here:
- Apple dropped support for 10.15 in Nov 2022, and OS X Lion that is
referenced is 10.7 (unsupported since late 2014)
- `xcode4` was basically always True because of the `>=` check (10.8 used
Xcode 5, and I have Xcode 10.2 on 10.14)
- `xcode51` was always False for modern-ish Xcode, because of the exact
version string matching
- Python 3.8 only supports OS X 10.9+; the Python 3.9.1+ universal installer
is macOS 11+ only, and Python 3.10 drops the x86_64 installer to deliver
only the universal installer.
All of this is to say, the only thing lost by dropping this code on modern Xcode
is that `os.environ['ARCHFLAGS'] = ''` is no longer set. But we probably
shouldn't be setting that anymore, as shown by the universal libraries now being
generated. I was able to `make local` and `python3 run-tests.py --local` with
python 3.9.9, Xcode 10.2, and macOS 10.14.6, and didn't incur any more than the
usual few test errors, so this should still work on some older versions of
macOS.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 04 Jan 2023 13:47:10 -0500 |
parents | e0c0545e2e55 |
children | ff4df0954742 |
comparison
equal
deleted
inserted
replaced
49877:f68b0a5d3211 | 49879:dd804d83822c |
---|---|
124 from distutils.errors import ( | 124 from distutils.errors import ( |
125 CCompilerError, | 125 CCompilerError, |
126 DistutilsError, | 126 DistutilsError, |
127 DistutilsExecError, | 127 DistutilsExecError, |
128 ) | 128 ) |
129 from distutils.sysconfig import get_python_inc, get_config_var | 129 from distutils.sysconfig import get_python_inc |
130 from distutils.version import StrictVersion | |
131 | |
132 # Explain to distutils.StrictVersion how our release candidates are versioned | |
133 StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') | |
134 | 130 |
135 | 131 |
136 def write_if_changed(path, content): | 132 def write_if_changed(path, content): |
137 """Write content to a file iff the content hasn't changed.""" | 133 """Write content to a file iff the content hasn't changed.""" |
138 if os.path.exists(path): | 134 if os.path.exists(path): |
1694 if os.name == 'nt': | 1690 if os.name == 'nt': |
1695 # Windows binary file versions for exe/dll files must have the | 1691 # Windows binary file versions for exe/dll files must have the |
1696 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 | 1692 # form W.X.Y.Z, where W,X,Y,Z are numbers in the range 0..65535 |
1697 setupversion = setupversion.split(r'+', 1)[0] | 1693 setupversion = setupversion.split(r'+', 1)[0] |
1698 | 1694 |
1699 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): | |
1700 version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[1].splitlines() | |
1701 if version: | |
1702 version = version[0].decode('utf-8') | |
1703 xcode4 = version.startswith('Xcode') and StrictVersion( | |
1704 version.split()[1] | |
1705 ) >= StrictVersion('4.0') | |
1706 xcode51 = re.match(r'^Xcode\s+5\.1', version) is not None | |
1707 else: | |
1708 # xcodebuild returns empty on OS X Lion with XCode 4.3 not | |
1709 # installed, but instead with only command-line tools. Assume | |
1710 # that only happens on >= Lion, thus no PPC support. | |
1711 xcode4 = True | |
1712 xcode51 = False | |
1713 | |
1714 # XCode 4.0 dropped support for ppc architecture, which is hardcoded in | |
1715 # distutils.sysconfig | |
1716 if xcode4: | |
1717 os.environ['ARCHFLAGS'] = '' | |
1718 | |
1719 # XCode 5.1 changes clang such that it now fails to compile if the | |
1720 # -mno-fused-madd flag is passed, but the version of Python shipped with | |
1721 # OS X 10.9 Mavericks includes this flag. This causes problems in all | |
1722 # C extension modules, and a bug has been filed upstream at | |
1723 # http://bugs.python.org/issue21244. We also need to patch this here | |
1724 # so Mercurial can continue to compile in the meantime. | |
1725 if xcode51: | |
1726 cflags = get_config_var('CFLAGS') | |
1727 if cflags and re.search(r'-mno-fused-madd\b', cflags) is not None: | |
1728 os.environ['CFLAGS'] = ( | |
1729 os.environ.get('CFLAGS', '') + ' -Qunused-arguments' | |
1730 ) | |
1731 | |
1732 setup( | 1695 setup( |
1733 name='mercurial', | 1696 name='mercurial', |
1734 version=setupversion, | 1697 version=setupversion, |
1735 author='Olivia Mackall and many others', | 1698 author='Olivia Mackall and many others', |
1736 author_email='mercurial@mercurial-scm.org', | 1699 author_email='mercurial@mercurial-scm.org', |