7575import _sitebuiltins
7676import io
7777import stat
78+ import warnings
7879
7980# Prefixes for site-packages; add additional prefixes like /usr/local here
8081PREFIXES = [sys .prefix , sys .exec_prefix ]
@@ -318,6 +319,15 @@ def joinuser(*args):
318319# Same to sysconfig.get_path('purelib', os.name+'_user')
319320def _get_path (userbase ):
320321 version = sys .version_info
322+ with warnings .catch_warnings ():
323+ # ignore DeprecationWarning on sys.abiflags change on Windows
324+ warnings .simplefilter ('ignore' , DeprecationWarning )
325+ abiflags = getattr (sys , 'abiflags' , '' )
326+ if 't' in abiflags :
327+ abi_thread = 't'
328+ else :
329+ abi_thread = ''
330+
321331 implementation = _get_implementation ()
322332 implementation_lower = implementation .lower ()
323333 if os .name == 'nt' :
@@ -327,7 +337,6 @@ def _get_path(userbase):
327337 if sys .platform == 'darwin' and sys ._framework :
328338 return f'{ userbase } /lib/{ implementation_lower } /site-packages'
329339
330- abi_thread = 't' if 't' in sys .abiflags else ''
331340 return f'{ userbase } /lib/python{ version [0 ]} .{ version [1 ]} { abi_thread } /site-packages'
332341
333342
@@ -396,8 +405,15 @@ def getsitepackages(prefixes=None):
396405
397406 implementation = _get_implementation ().lower ()
398407 ver = sys .version_info
399- if os .name != 'nt' :
400- abi_thread = 't' if 't' in sys .abiflags else ''
408+ with warnings .catch_warnings ():
409+ # ignore DeprecationWarning on sys.abiflags change on Windows
410+ warnings .simplefilter ('ignore' , DeprecationWarning )
411+ abiflags = getattr (sys , 'abiflags' , '' )
412+ if 't' in abiflags :
413+ abi_thread = 't'
414+ else :
415+ abi_thread = ''
416+ if os .sep == '/' :
401417 libdirs = [sys .platlibdir ]
402418 if sys .platlibdir != "lib" :
403419 libdirs .append ("lib" )
0 commit comments