@@ -60,6 +60,12 @@ def _should_use_sysconfig() -> bool:
60
60
61
61
_USE_SYSCONFIG = _should_use_sysconfig ()
62
62
63
+ if not _USE_SYSCONFIG :
64
+ # Import distutils lazily to avoid deprecation warnings,
65
+ # but import it soon enough that it is in memory and available during
66
+ # a pip reinstall.
67
+ from . import _distutils
68
+
63
69
# Be noisy about incompatibilities if this platforms "should" be using
64
70
# sysconfig, but is explicitly opting out and using distutils instead.
65
71
if _USE_SYSCONFIG_DEFAULT and not _USE_SYSCONFIG :
@@ -241,8 +247,6 @@ def get_scheme(
241
247
if _USE_SYSCONFIG :
242
248
return new
243
249
244
- from . import _distutils
245
-
246
250
old = _distutils .get_scheme (
247
251
dist_name ,
248
252
user = user ,
@@ -407,8 +411,6 @@ def get_bin_prefix() -> str:
407
411
if _USE_SYSCONFIG :
408
412
return new
409
413
410
- from . import _distutils
411
-
412
414
old = _distutils .get_bin_prefix ()
413
415
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "bin_prefix" ):
414
416
_log_context ()
@@ -442,8 +444,6 @@ def get_purelib() -> str:
442
444
if _USE_SYSCONFIG :
443
445
return new
444
446
445
- from . import _distutils
446
-
447
447
old = _distutils .get_purelib ()
448
448
if _looks_like_deb_system_dist_packages (old ):
449
449
return old
@@ -488,8 +488,6 @@ def get_prefixed_libs(prefix: str) -> List[str]:
488
488
if _USE_SYSCONFIG :
489
489
return _deduplicated (new_pure , new_plat )
490
490
491
- from . import _distutils
492
-
493
491
old_pure , old_plat = _distutils .get_prefixed_libs (prefix )
494
492
old_lib_paths = _deduplicated (old_pure , old_plat )
495
493
0 commit comments