-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent abi3 from being used with no-GIL interpreter #4424
base: main
Are you sure you want to change the base?
Conversation
@dholth, @bastimeyer, this is a draft that expands on #4420 (comment) (I just wanted to make sure the information why abi3 is not used is present in the logs). Does it make sense to still use the given I don't have an approach to test this in the CI yet... Suggestions are welcome. |
setuptools/command/bdist_wheel.py
Outdated
@@ -363,6 +354,24 @@ def get_tag(self) -> tuple[str, str, str]: | |||
), f"would build wheel with unsupported tag {tag}" | |||
return tag | |||
|
|||
def _get_tag_impure(self, plat_name: str) -> tuple[str, str, str]: | |||
impl_name = tags.interpreter_name() | |||
impl_ver = tags.interpreter_version() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As explained in the issue thread, impl_ver
does not include abi flags. Here's the implementation of tags.interpreter_version()
:
setuptools/setuptools/_vendor/packaging/tags.py
Lines 535 to 544 in f91fa3d
def interpreter_version(*, warn: bool = False) -> str: | |
""" | |
Returns the version of the running interpreter. | |
""" | |
version = _get_config_var("py_version_nodot", warn=warn) | |
if version: | |
version = str(version) | |
else: | |
version = _version_nodot(sys.version_info[:2]) | |
return version |
>>> import sys,sysconfig
>>> sysconfig.get_config_var("py_version_nodot")
'313'
>>> sys.abiflags
't'
>>> sys.version_info[:2]
(3, 13)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bastimeyer.
It seems that we can use sys.abiflags
then...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code to reflect my latest understanding.
ad24375
to
40d29d2
Compare
setuptools/command/bdist_wheel.py
Outdated
f"`Py_GIL_DISABLED` ({sys.abiflags=!r}).", | ||
see_url="https://github.com/python/cpython/issues/111506", | ||
) | ||
self.py_limited_api = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to deal with the following problem however:
The extensions themselves define py_limited_api
like in https://github.com/Legrandin/pycryptodome/blob/39b5a627dab9124da0fb9d15a2f3a19434d96565/setup.py#L286C9-L286C28.
Not sure how that will interact with this.
Maybe the best is to just raise an exception and require the developer to be mindful about the compatibility with py_limited_api
(and change their setup.py
accordingly to react to the current version of Python being used)?
3bf792d
to
2fbb280
Compare
I'm sorry, but I can't help with this, because as explained in the issue thread, I don't have any experience with Python C-extensions, so I don't know the specific requirements and the best way forward in order to solve this. The issue was opened by me purely from the perspective of someone who has a dependency on a project with C-extensions and abi3 wheels, where I ran into these build issues. The maintainers of those projects which build extensions based on the limited API will need to provide feedback. I've already asked the maintainers of pycryptodome in the issue I've opened there, but I can ask again and link to this pull request, too. |
Summary of changes
Closes #4420
Pull Request Checklist
newsfragments/
.(See documentation for details)