Skip to content
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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abravalheri
Copy link
Contributor

Summary of changes

Closes #4420

Pull Request Checklist

@abravalheri abravalheri requested a review from dholth June 17, 2024 18:29
@abravalheri
Copy link
Contributor Author

@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 py_limited_api and just ignore abi3, or we should also discard the given py_limited_api? (If the second option is preferable, then it would make more sense to me to raise an exception due to incompatible configuration).

I don't have an approach to test this in the CI yet... Suggestions are welcome.

@@ -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()

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():

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)

Copy link
Contributor Author

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...

Copy link
Contributor Author

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.

@abravalheri abravalheri force-pushed the issue-4420 branch 2 times, most recently from ad24375 to 40d29d2 Compare June 19, 2024 08:41
f"`Py_GIL_DISABLED` ({sys.abiflags=!r}).",
see_url="https://github.com/python/cpython/issues/111506",
)
self.py_limited_api = False
Copy link
Contributor Author

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)?

@abravalheri abravalheri force-pushed the issue-4420 branch 2 times, most recently from 3bf792d to 2fbb280 Compare June 21, 2024 08:05
@bastimeyer
Copy link

abravalheri requested a review from bastimeyer last week

#4424 (comment)

I don't know how to deal with the following problem however:

The extensions themselves define py_limited_api like in Legrandin/pycryptodome@39b5a62/setup.py#L286C9-L286C28

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Can't build wheels on CPython 3.13t (no GIL / PEP 703) when bdist_wheel's py-limited-api option is set
2 participants