From 13fe45852fbb17b3fbb582e3c836118781026e1f Mon Sep 17 00:00:00 2001 From: Ryan May Date: Fri, 17 Jul 2020 17:25:05 -0600 Subject: [PATCH 1/3] ENH: Add version check for mac sdk version This specifically lists the macOS SDK version (currently 10.11) needed to build the osx backend. It also turns on compiler warnings for when code uses features newer than the minimum version (and makes warnings errors for this file). --- setupext.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setupext.py b/setupext.py index 21bec048bdd4..88f6b36d48e2 100644 --- a/setupext.py +++ b/setupext.py @@ -657,6 +657,8 @@ def get_extensions(self): 'src/_macosx.m' ] ext = Extension('matplotlib.backends._macosx', sources) + ext.extra_compile_args.extend(['-mmacosx-version-min=10.9', + '-Wunguarded-availability', '-Werror']) ext.extra_link_args.extend(['-framework', 'Cocoa']) if platform.python_implementation().lower() == 'pypy': ext.extra_compile_args.append('-DPYPY=1') From ff368f9fab2907e2343b9d96a4ccf4052f1a843a Mon Sep 17 00:00:00 2001 From: Ryan May Date: Sat, 18 Jul 2020 15:22:34 -0600 Subject: [PATCH 2/3] Protect use of newer macOS APIs Don't unconditionally use the newer properties, but check the available version. This allows us to continue to target 10.9 by default and eliminate any hard-coded deployment version. --- setupext.py | 3 +-- src/_macosx.m | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setupext.py b/setupext.py index 88f6b36d48e2..3ed109911932 100644 --- a/setupext.py +++ b/setupext.py @@ -657,8 +657,7 @@ def get_extensions(self): 'src/_macosx.m' ] ext = Extension('matplotlib.backends._macosx', sources) - ext.extra_compile_args.extend(['-mmacosx-version-min=10.9', - '-Wunguarded-availability', '-Werror']) + ext.extra_compile_args.extend(['-Wunguarded-availability', '-Werror']) ext.extra_link_args.extend(['-framework', 'Cocoa']) if platform.python_implementation().lower() == 'pypy': ext.extra_compile_args.append('-DPYPY=1') diff --git a/src/_macosx.m b/src/_macosx.m index 9ffa4a4404d9..1d559d195b73 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -1184,8 +1184,10 @@ -(void)save_figure:(id)sender rect.size.height = 0; rect.origin.x += height; NSTextView* messagebox = [[NSTextView alloc] initWithFrame: rect]; - messagebox.textContainer.maximumNumberOfLines = 2; - messagebox.textContainer.lineBreakMode = NSLineBreakByTruncatingTail; + if (@available(macOS 10.11, *)) { + messagebox.textContainer.maximumNumberOfLines = 2; + messagebox.textContainer.lineBreakMode = NSLineBreakByTruncatingTail; + } [messagebox setFont: font]; [messagebox setDrawsBackground: NO]; [messagebox setSelectable: NO]; From 8ad6a3df294a5b3f17f9cf36e7d045584eb1038c Mon Sep 17 00:00:00 2001 From: Ryan May Date: Sat, 18 Jul 2020 16:28:48 -0600 Subject: [PATCH 3/3] Only make the unguarded API warning an error We have other deprecated constants that flags warnings in CI. Unfortunately, the deprecations occur in the same version when the new names are introduced, and we can't rely on those being available yet. --- setupext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setupext.py b/setupext.py index 3ed109911932..958a01ae1093 100644 --- a/setupext.py +++ b/setupext.py @@ -657,7 +657,7 @@ def get_extensions(self): 'src/_macosx.m' ] ext = Extension('matplotlib.backends._macosx', sources) - ext.extra_compile_args.extend(['-Wunguarded-availability', '-Werror']) + ext.extra_compile_args.extend(['-Werror=unguarded-availability']) ext.extra_link_args.extend(['-framework', 'Cocoa']) if platform.python_implementation().lower() == 'pypy': ext.extra_compile_args.append('-DPYPY=1')