From 4b73bfaf36b40ad94e816f102a5a77676a703b88 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 17 Jan 2025 12:09:22 -0700 Subject: [PATCH 1/5] Fix crash formatting error message --- setuptools/command/bdist_wheel.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index d9e1eb974f..fd3e845c47 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -291,10 +291,15 @@ def _validate_py_limited_api(self) -> None: raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'") if sysconfig.get_config_var("Py_GIL_DISABLED"): + # sys.abiflags is only defined on POSIX + if getattr(sys, "abiflags", ""): + abinote = f" ({sys.abiflags=!r}). " + else: + abinote = ". " raise ValueError( f"`py_limited_api={self.py_limited_api!r}` not supported. " "`Py_LIMITED_API` is currently incompatible with " - f"`Py_GIL_DISABLED` ({sys.abiflags=!r}). " + f"`Py_GIL_DISABLED`{abinote}" "See https://github.com/python/cpython/issues/111506." ) From 8db1f5e67c18d5ba99750fe9be7a02778ed81bca Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 17 Jan 2025 12:15:06 -0700 Subject: [PATCH 2/5] add release note entry --- newsfragments/4809.bugfix.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 newsfragments/4809.bugfix.rst diff --git a/newsfragments/4809.bugfix.rst b/newsfragments/4809.bugfix.rst new file mode 100644 index 0000000000..288e3f686a --- /dev/null +++ b/newsfragments/4809.bugfix.rst @@ -0,0 +1,2 @@ +Fixed crash generating error message printed when building wheels for the +free-threaded build using the limited API. -- by :user:`ngoldbaum` From f049c9a5423248b0e1230c4a1cf1cb1b133d7ce5 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Sun, 19 Jan 2025 08:26:31 -0700 Subject: [PATCH 3/5] Update bdist_wheel.py Co-authored-by: Avasam --- setuptools/command/bdist_wheel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index fd3e845c47..cc48077dbc 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -292,7 +292,7 @@ def _validate_py_limited_api(self) -> None: if sysconfig.get_config_var("Py_GIL_DISABLED"): # sys.abiflags is only defined on POSIX - if getattr(sys, "abiflags", ""): + if hasattr(sys, "abiflags"): abinote = f" ({sys.abiflags=!r}). " else: abinote = ". " From 3bde6efc7e0ad2da92e27bce76aa41805f7240ab Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 20 Jan 2025 08:49:11 -0700 Subject: [PATCH 4/5] Update setuptools/command/bdist_wheel.py Co-authored-by: Anderson Bravalheri --- setuptools/command/bdist_wheel.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index cc48077dbc..aafff9191e 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -291,11 +291,6 @@ def _validate_py_limited_api(self) -> None: raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'") if sysconfig.get_config_var("Py_GIL_DISABLED"): - # sys.abiflags is only defined on POSIX - if hasattr(sys, "abiflags"): - abinote = f" ({sys.abiflags=!r}). " - else: - abinote = ". " raise ValueError( f"`py_limited_api={self.py_limited_api!r}` not supported. " "`Py_LIMITED_API` is currently incompatible with " From d92a59556223bb1a9a86fb94b10d59a8c018b0f7 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 20 Jan 2025 08:49:17 -0700 Subject: [PATCH 5/5] Update setuptools/command/bdist_wheel.py Co-authored-by: Anderson Bravalheri --- setuptools/command/bdist_wheel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index aafff9191e..bcd176f98e 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -294,7 +294,7 @@ def _validate_py_limited_api(self) -> None: raise ValueError( f"`py_limited_api={self.py_limited_api!r}` not supported. " "`Py_LIMITED_API` is currently incompatible with " - f"`Py_GIL_DISABLED`{abinote}" + "`Py_GIL_DISABLED`." "See https://github.com/python/cpython/issues/111506." )