45
45
46
46
_PLATLIBDIR : str = getattr (sys , "platlibdir" , "lib" )
47
47
48
+ _USE_SYSCONFIG = sys .version_info >= (3 , 10 )
49
+
48
50
49
51
def _looks_like_bpo_44860 () -> bool :
50
52
"""The resolution to bpo-44860 will change this incorrect platlib.
@@ -190,15 +192,18 @@ def get_scheme(
190
192
isolated : bool = False ,
191
193
prefix : Optional [str ] = None ,
192
194
) -> Scheme :
193
- old = _distutils .get_scheme (
195
+ new = _sysconfig .get_scheme (
194
196
dist_name ,
195
197
user = user ,
196
198
home = home ,
197
199
root = root ,
198
200
isolated = isolated ,
199
201
prefix = prefix ,
200
202
)
201
- new = _sysconfig .get_scheme (
203
+ if _USE_SYSCONFIG :
204
+ return new
205
+
206
+ old = _distutils .get_scheme (
202
207
dist_name ,
203
208
user = user ,
204
209
home = home ,
@@ -333,8 +338,11 @@ def get_scheme(
333
338
334
339
335
340
def get_bin_prefix () -> str :
336
- old = _distutils .get_bin_prefix ()
337
341
new = _sysconfig .get_bin_prefix ()
342
+ if _USE_SYSCONFIG :
343
+ return new
344
+
345
+ old = _distutils .get_bin_prefix ()
338
346
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "bin_prefix" ):
339
347
_log_context ()
340
348
return old
@@ -363,8 +371,11 @@ def _looks_like_deb_system_dist_packages(value: str) -> bool:
363
371
364
372
def get_purelib () -> str :
365
373
"""Return the default pure-Python lib location."""
366
- old = _distutils .get_purelib ()
367
374
new = _sysconfig .get_purelib ()
375
+ if _USE_SYSCONFIG :
376
+ return new
377
+
378
+ old = _distutils .get_purelib ()
368
379
if _looks_like_deb_system_dist_packages (old ):
369
380
return old
370
381
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "purelib" ):
@@ -374,19 +385,32 @@ def get_purelib() -> str:
374
385
375
386
def get_platlib () -> str :
376
387
"""Return the default platform-shared lib location."""
377
- old = _distutils .get_platlib ()
378
388
new = _sysconfig .get_platlib ()
389
+ if _USE_SYSCONFIG :
390
+ return new
391
+
392
+ old = _distutils .get_platlib ()
379
393
if _looks_like_deb_system_dist_packages (old ):
380
394
return old
381
395
if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "platlib" ):
382
396
_log_context ()
383
397
return old
384
398
385
399
400
+ def _deduplicated (v1 : str , v2 : str ) -> List [str ]:
401
+ """Deduplicate values from a list."""
402
+ if v1 == v2 :
403
+ return [v1 ]
404
+ return [v1 , v2 ]
405
+
406
+
386
407
def get_prefixed_libs (prefix : str ) -> List [str ]:
387
408
"""Return the lib locations under ``prefix``."""
388
- old_pure , old_plat = _distutils .get_prefixed_libs (prefix )
389
409
new_pure , new_plat = _sysconfig .get_prefixed_libs (prefix )
410
+ if _USE_SYSCONFIG :
411
+ return _deduplicated (new_pure , new_plat )
412
+
413
+ old_pure , old_plat = _distutils .get_prefixed_libs (prefix )
390
414
391
415
warned = [
392
416
_warn_if_mismatch (
@@ -403,6 +427,4 @@ def get_prefixed_libs(prefix: str) -> List[str]:
403
427
if any (warned ):
404
428
_log_context (prefix = prefix )
405
429
406
- if old_pure == old_plat :
407
- return [old_pure ]
408
- return [old_pure , old_plat ]
430
+ return _deduplicated (old_pure , old_plat )
0 commit comments