@@ -240,44 +240,19 @@ def get_tag(self) -> Tuple[str, str, str]:
240240 dist .cmdclass ["bdist_wheel" ] = bdist_wheel_rust_extension
241241
242242
243- def patch_distutils_build () -> None :
244- """Patch distutils to use `has_ext_modules()`
245-
246- See https://github.com/pypa/distutils/pull/43
247- """
248- from distutils .command import build as _build
249-
250- class build (_build .build ):
251- # Missing type def from distutils.cmd.Command; add it here for now
252- distribution : Distribution
253-
254- def finalize_options (self ) -> None :
255- build_lib_user_specified = self .build_lib is not None
256- super ().finalize_options ()
257- if not build_lib_user_specified :
258- if self .distribution .has_ext_modules (): # type: ignore[attr-defined]
259- self .build_lib = self .build_platlib
260- else :
261- self .build_lib = self .build_purelib
262-
263- _build .build = build # type: ignore[misc]
264-
265-
266243def rust_extensions (
267244 dist : Distribution , attr : Literal ["rust_extensions" ], value : List [RustExtension ]
268245) -> None :
269246 assert attr == "rust_extensions"
270247 has_rust_extensions = len (value ) > 0
271248
272- # Monkey patch has_ext_modules to include Rust extensions; pairs with
273- # patch_distutils_build above.
249+ # Monkey patch has_ext_modules to include Rust extensions.
274250 #
275251 # has_ext_modules is missing from Distribution typing.
276252 orig_has_ext_modules = dist .has_ext_modules # type: ignore[attr-defined]
277253 dist .has_ext_modules = lambda : (orig_has_ext_modules () or has_rust_extensions ) # type: ignore[attr-defined]
278254
279255 if has_rust_extensions :
280- patch_distutils_build ()
281256 add_rust_extension (dist )
282257
283258
0 commit comments