|
7 | 7 | from distutils.cmd import Command |
8 | 8 | from distutils.errors import ( |
9 | 9 | CompileError, DistutilsExecError, DistutilsFileError, |
10 | | - DistutilsPlatformError) |
| 10 | + DistutilsPlatformError, DistutilsSetupError) |
11 | 11 |
|
12 | 12 | from .extension import RustExtension |
13 | 13 | from .utils import cpython_feature, get_rust_version |
@@ -166,10 +166,18 @@ def run(self): |
166 | 166 | version = get_rust_version() |
167 | 167 |
|
168 | 168 | for ext in self.extensions: |
169 | | - rust_version = ext.get_rust_version() |
170 | | - if rust_version is not None and version not in rust_version: |
171 | | - raise DistutilsPlatformError( |
172 | | - "Rust %s does not match extension requirement %s" % ( |
173 | | - version, ext.rust_version)) |
174 | | - |
175 | | - self.build_extension(ext) |
| 169 | + try: |
| 170 | + rust_version = ext.get_rust_version() |
| 171 | + if rust_version is not None and version not in rust_version: |
| 172 | + raise DistutilsPlatformError( |
| 173 | + "Rust %s does not match extension requirement %s" % ( |
| 174 | + version, ext.rust_version)) |
| 175 | + |
| 176 | + self.build_extension(ext) |
| 177 | + except (DistutilsSetupError, DistutilsFileError, DistutilsExecError, |
| 178 | + DistutilsPlatformError, CompileError) as e: |
| 179 | + if not ext.optional: |
| 180 | + raise |
| 181 | + else: |
| 182 | + print('Build optional Rust extension %s failed.' % ext.name) |
| 183 | + print(str(e)) |
0 commit comments