Skip to content

Commit 7884a62

Browse files
committed
Simplify sys.abiflags in sysconfig and site
1 parent 56c7d91 commit 7884a62

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

Lib/site.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import _sitebuiltins
7676
import io
7777
import stat
78-
import warnings
7978

8079
# Prefixes for site-packages; add additional prefixes like /usr/local here
8180
PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -319,15 +318,6 @@ def joinuser(*args):
319318
# Same to sysconfig.get_path('purelib', os.name+'_user')
320319
def _get_path(userbase):
321320
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-
331321
implementation = _get_implementation()
332322
implementation_lower = implementation.lower()
333323
if os.name == 'nt':
@@ -337,6 +327,7 @@ def _get_path(userbase):
337327
if sys.platform == 'darwin' and sys._framework:
338328
return f'{userbase}/lib/{implementation_lower}/site-packages'
339329

330+
abi_thread = 't' if 't' in sys.abiflags else ''
340331
return f'{userbase}/lib/python{version[0]}.{version[1]}{abi_thread}/site-packages'
341332

342333

@@ -405,15 +396,8 @@ def getsitepackages(prefixes=None):
405396

406397
implementation = _get_implementation().lower()
407398
ver = sys.version_info
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 == '/':
399+
if os.name != 'nt':
400+
abi_thread = 't' if 't' in sys.abiflags else ''
417401
libdirs = [sys.platlibdir]
418402
if sys.platlibdir != "lib":
419403
libdirs.append("lib")

Lib/sysconfig/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ def get_default_scheme():
325325

326326
def get_makefile_filename():
327327
"""Return the path of the Makefile."""
328-
import warnings
329328

330329
# GH-127429: When cross-compiling, use the Makefile from the target, instead of the host Python.
331330
if cross_base := os.environ.get('_PYTHON_PROJECT_BASE'):
@@ -334,12 +333,7 @@ def get_makefile_filename():
334333
if _PYTHON_BUILD:
335334
return os.path.join(_PROJECT_BASE, "Makefile")
336335

337-
with warnings.catch_warnings():
338-
# ignore DeprecationWarning on sys.abiflags change on Windows
339-
warnings.simplefilter('ignore', DeprecationWarning)
340-
has_abiflags = hasattr(sys, 'abiflags')
341-
342-
if has_abiflags:
336+
if os.name == 'nt':
343337
config_dir_name = f'config-{_PY_VERSION_SHORT}{sys.abiflags}'
344338
else:
345339
config_dir_name = 'config'

0 commit comments

Comments
 (0)