Skip to content

Commit 97a9db1

Browse files
committed
Account for possibility bdist_wheel is not installed
1 parent 94f6781 commit 97a9db1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

setuptools_rust/setuptools_ext.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sysconfig
55
import logging
66

7-
from typing import List, Set, Tuple, Type, TypeVar, cast
7+
from typing import List, Optional, Set, Tuple, Type, TypeVar, cast
88
from functools import partial
99

1010
from setuptools.command.build_ext import build_ext
@@ -163,14 +163,18 @@ def run(self) -> None:
163163
build_rust.inplace = self.inplace
164164
build_rust.target = self.target
165165
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
170167
build_rust.run()
171168

172169
build_ext_base_class.run(self)
173170

171+
def _get_wheel_plat_name(self) -> Optional[str]:
172+
try:
173+
cmd = self.distribution.get_command_obj("bdist_wheel")
174+
return cast(Optional[str], cmd.plat_name)
175+
except Exception: # unlikely scenario: `wheel` not installed
176+
return None
177+
174178
dist.cmdclass["build_ext"] = build_ext_rust_extension
175179

176180
clean_base_class = dist.cmdclass.get("clean")

0 commit comments

Comments
 (0)