You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that setuptools has incorporated bdist_wheel.py as setuptools/command/bdist_wheel.py, the issue pypa/wheel#461 that was previously fixable by changing wheel is now fixable by changing setuptools, so I'm reporting it in updated form here.
When building a wheel with "python -m build --wheel" on Windows, it ends up executing wheel/bdist_wheel.py, and outputs this warning to screen:
if get_flag("Py_DEBUG", hasattr(sys, "gettotalrefcount"), warn=(impl == "cp")):
This is because setuptools/command/bdist_wheel.py has a local implementation of get_abi_tag() that's called by bdist_wheel.get_tag(), which is called by bdist_wheel.run(), bdist_wheel.write_wheelfile(), and editable_wheel._create_wheel_file(). This local implementation isn't able to detect the debug attribute properly on Windows, so it issues a warning.
But setuptools/_vendor/packaging/tags.py has another implementation of this functionality in _cpython_abis() that detects the debug attribute more correctly:
py_version = tuple(py_version) # To allow for version comparison.
abis = []
version = _version_nodot(py_version[:2])
threading = debug = pymalloc = ucs4 = ""
with_debug = _get_config_var("Py_DEBUG", warn)
has_refcount = hasattr(sys, "gettotalrefcount")
# Windows doesn't set Py_DEBUG, so checking for support of debug-compiled
# extension modules is the best option.
# https://github.com/pypa/pip/issues/3383#issuecomment-173267692
has_ext = "_d.pyd" in EXTENSION_SUFFIXES
if with_debug or (with_debug is None and (has_refcount or has_ext)):
debug = "d"
if py_version >= (3, 13) and _get_config_var("Py_GIL_DISABLED", warn):
threading = "t"
if py_version < (3, 8):
with_pymalloc = _get_config_var("WITH_PYMALLOC", warn)
if with_pymalloc or with_pymalloc is None:
pymalloc = "m"
if py_version < (3, 3):
unicode_size = _get_config_var("Py_UNICODE_SIZE", warn)
if unicode_size == 4 or (
unicode_size is None and sys.maxunicode == 0x10FFFF
):
ucs4 = "u"
elif debug:
# Debug builds can also load "normal" extension modules.
# We can also assume no UCS-4 or pymalloc requirement.
abis.append(f"cp{version}{threading}")
abis.insert(0, f"cp{version}{threading}{debug}{pymalloc}{ucs4}")
return abis
tags._cpython_abis() is called by tags.cpython_tags(), which is called by tags.sys_tags(). See pypa/packaging#194 and pypa/packaging#172 for work that improved this debug attribute detection on Windows.
setuptools/command/bdist_wheel.py already has:
from packaging import tags, version as _packaging_version
...and uses tags.interpreter_name(), tags.interpreter_version(), and tags.sys_tags(). So it seems like using the tags module a little more extensively should be safe, as long as it gives the same behavior on all Python versions still supported by setuptools (>=3.8).
It seems to me that the local implementation of get_abi_tag() could be replaced with an appropriate call to tags.sys_tags(), and get_abi_tag() could be removed. The current code does:
impl_ver = tags.interpreter_version()
impl = impl_name + impl_ver
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and (impl_name + impl_ver).startswith("cp3"):
impl = self.py_limited_api
abi_tag = "abi3"
else:
abi_tag = str(get_abi_tag()).lower()
tag = (impl, abi_tag, plat_name)
# issue gh-374: allow overriding plat_name
supported_tags = [
(t.interpreter, t.abi, plat_name) for t in tags.sys_tags()
]
assert (
tag in supported_tags
), f"would build wheel with unsupported tag {tag}"
...where I could imagine it instead doing:
impl_ver = tags.interpreter_version()
impl = impl_name + impl_ver
# issue gh-374: allow overriding plat_name
supported_tags = [
(t.interpreter, t.abi, plat_name) for t in tags.sys_tags()
]
# We don't work on CPython 3.1, 3.0.
if self.py_limited_api and (impl_name + impl_ver).startswith("cp3"):
impl = self.py_limited_api
abi_tag = "abi3"
tag = (impl, abi_tag, plat_name)
assert (
tag in supported_tags
), f"would build wheel with unsupported tag {tag}"
else:
tag = supported_tags[0]
This change works for my use case and avoids the warning.
If this isn't feasible for some reason, another option would be to change the local implementation of get_abi_tag() to imitate the relevant packaging.tags._cpython_abis() code that detects the debug and with_pymalloc attributes, with a particular care not to warn on Windows in an expected situation that is immediately going to be rectified by an appropriate alternate detection mechanism. This is more complicated, so I won't attempt to suggest the exact patch for this option.
Expected behavior
Not getting this warning being output to screen:
if get_flag("Py_DEBUG", hasattr(sys, "gettotalrefcount"), warn=(impl == "cp")):
How to Reproduce
Run commands:
mkdir setuptoolsbug
mkdir setuptoolsbug\mymod
cd setuptoolsbug\mymod
Create setuptoolsbug\mymod\setup.py:
## forces the wheelname to include the binary component
class BinaryDistribution(setuptools.dist.Distribution):
def has_ext_modules(self):
return True
setuptools.setup(
name = 'mymod',
version = "1.0.0.0",
description = 'MyMod',
packages = setuptools.find_packages(),
include_package_data=True,
python_requires='>=3.9',
distclass = BinaryDistribution
)
setuptools version
setuptools==74.1.2
Python version
Python 3.9.13
OS
Windows
Additional environment information
No response
Description
Now that setuptools has incorporated bdist_wheel.py as setuptools/command/bdist_wheel.py, the issue pypa/wheel#461 that was previously fixable by changing wheel is now fixable by changing setuptools, so I'm reporting it in updated form here.
When building a wheel with "python -m build --wheel" on Windows, it ends up executing wheel/bdist_wheel.py, and outputs this warning to screen:
This is because setuptools/command/bdist_wheel.py has a local implementation of get_abi_tag() that's called by bdist_wheel.get_tag(), which is called by bdist_wheel.run(), bdist_wheel.write_wheelfile(), and editable_wheel._create_wheel_file(). This local implementation isn't able to detect the debug attribute properly on Windows, so it issues a warning.
But setuptools/_vendor/packaging/tags.py has another implementation of this functionality in _cpython_abis() that detects the debug attribute more correctly:
tags._cpython_abis() is called by tags.cpython_tags(), which is called by tags.sys_tags(). See pypa/packaging#194 and pypa/packaging#172 for work that improved this debug attribute detection on Windows.
setuptools/command/bdist_wheel.py already has:
...and uses tags.interpreter_name(), tags.interpreter_version(), and tags.sys_tags(). So it seems like using the tags module a little more extensively should be safe, as long as it gives the same behavior on all Python versions still supported by setuptools (>=3.8).
It seems to me that the local implementation of get_abi_tag() could be replaced with an appropriate call to tags.sys_tags(), and get_abi_tag() could be removed. The current code does:
...where I could imagine it instead doing:
This change works for my use case and avoids the warning.
If this isn't feasible for some reason, another option would be to change the local implementation of get_abi_tag() to imitate the relevant packaging.tags._cpython_abis() code that detects the debug and with_pymalloc attributes, with a particular care not to warn on Windows in an expected situation that is immediately going to be rectified by an appropriate alternate detection mechanism. This is more complicated, so I won't attempt to suggest the exact patch for this option.
Expected behavior
Not getting this warning being output to screen:
How to Reproduce
Run commands:
mkdir setuptoolsbug
mkdir setuptoolsbug\mymod
cd setuptoolsbug\mymod
Create setuptoolsbug\mymod\setup.py:
Output
The text was updated successfully, but these errors were encountered: