|
4 | 4 | import sysconfig
|
5 | 5 | import logging
|
6 | 6 |
|
7 |
| -from typing import List, Set, Tuple, Type, TypeVar, cast |
| 7 | +from typing import List, Optional, Set, Tuple, Type, TypeVar, cast |
8 | 8 | from functools import partial
|
9 | 9 |
|
10 | 10 | from setuptools.command.build_ext import build_ext
|
@@ -163,14 +163,20 @@ def run(self) -> None:
|
163 | 163 | build_rust.inplace = self.inplace
|
164 | 164 | build_rust.target = self.target
|
165 | 165 | build_rust.verbose = self.verbose
|
166 |
| - |
167 |
| - bdist_wheel = self.distribution.get_command_obj("bdist_wheel") |
168 |
| - plat_name = bdist_wheel.plat_name or self.plat_name |
169 |
| - build_rust.plat_name = plat_name |
| 166 | + build_rust.plat_name = self._get_wheel_plat_name() or self.plat_name |
170 | 167 | build_rust.run()
|
171 | 168 |
|
172 | 169 | build_ext_base_class.run(self)
|
173 | 170 |
|
| 171 | + def _get_wheel_plat_name(self) -> Optional[str]: |
| 172 | + try: |
| 173 | + bdist_wheel = self.distribution.get_command_obj("bdist_wheel") |
| 174 | + return cast(Optional[str], bdist_wheel.plat_name) |
| 175 | + except Exception: |
| 176 | + # `wheel` is not installed. |
| 177 | + options = self.distribution.get_cmdline_options().get("bdist_wheel", {}) |
| 178 | + return cast(Optional[str], options.get("plat-name")) |
| 179 | + |
174 | 180 | dist.cmdclass["build_ext"] = build_ext_rust_extension
|
175 | 181 |
|
176 | 182 | clean_base_class = dist.cmdclass.get("clean")
|
|
0 commit comments