|
15 | 15 | error = """
|
16 | 16 | Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
|
17 | 17 | Beginning with Matplotlib 3.0, Python 3.5 and above is required.
|
18 |
| -
|
19 | 18 | This may be due to an out of date pip.
|
20 |
| -
|
21 | 19 | Make sure you have pip >= 9.0.1.
|
22 | 20 | """
|
23 | 21 | sys.exit(error)
|
24 | 22 |
|
| 23 | +import subprocess |
25 | 24 | # The setuptools version of sdist adds a setup.cfg file to the tree.
|
26 | 25 | # We don't want that, so we simply remove it, and it will fall back to
|
27 | 26 | # vanilla distutils.
|
@@ -105,10 +104,27 @@ def build_extensions(self):
|
105 | 104 | self.compiler.compiler_so.remove('-Wstrict-prototypes')
|
106 | 105 | except (ValueError, AttributeError):
|
107 | 106 | pass
|
| 107 | + if self._xcode_gte_10(): |
| 108 | + # If compiling using Xcode >= 10, need to manually specify the |
| 109 | + # -stdlib flag because libstdc++ is no longer available |
| 110 | + for mod in self.distribution.ext_modules: |
| 111 | + mod.extra_compile_args = ['-stdlib=libc++'] |
| 112 | + mod.extra_link_args = ['-stdlib=libc++'] |
108 | 113 | for package in good_packages:
|
109 | 114 | package.do_custom_build()
|
110 | 115 | return super().build_extensions()
|
111 | 116 |
|
| 117 | + def _xcode_gte_10(self): |
| 118 | + if sys.platform != "darwin": |
| 119 | + return False |
| 120 | + # Returns True if compiler is from Xcode version >= 10 |
| 121 | + compiler_version = str(subprocess.check_output( |
| 122 | + self.compiler.compiler + ['--version'], universal_newlines=True)) |
| 123 | + compiler_version = compiler_version.split(' ') |
| 124 | + return ((compiler_version[0] == 'Apple') and |
| 125 | + (compiler_version[1] == 'LLVM') and |
| 126 | + (int(compiler_version[3].split('.')[0]) >= 10)) |
| 127 | + |
112 | 128 |
|
113 | 129 | cmdclass = versioneer.get_cmdclass()
|
114 | 130 | cmdclass['test'] = NoopTestCommand
|
|
0 commit comments