Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-127405: Emit a deprecation warning about a future change ofsys.abiflags availability on Windows#131717

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
XuehaiPan wants to merge61 commits intopython:main
base:main
Choose a base branch
Loading
fromXuehaiPan:windows-add-sys-abiflags

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPanXuehaiPan commentedMar 25, 2025
edited
Loading

Emit a deprecation warning when accessing thesys.abiflags member if it is absent:

>>>importsys>>>getattr(sys,'abiflags',None)# on Windows<python-input-1>:1:DeprecationWarning:sys.abiflagswillbesettoameaningfulvalueonallplatformsinPython3.16insteadofabsent>>>hasattr(sys,'abiflags')# on Windows<python-input-2>:1:DeprecationWarning:sys.abiflagswillbesettoameaningfulvalueonallplatformsinPython3.16insteadofabsentFalse

See also:


📚 Documentation preview 📚:https://cpython-previews--131717.org.readthedocs.build/

@XuehaiPanXuehaiPan changed the titlegh-27405: Emit a deprecation warning about a future change ofsys.abiflags availability on Windowsgh-127405: Emit a deprecation warning about a future change ofsys.abiflags availability on WindowsMar 25, 2025
@colesburycolesbury requested a review fromzoobaMarch 25, 2025 21:45
@colesbury
Copy link
Contributor

Given the alternative of usingsysconfig and PEP 780's proposedsys.abi_features, I'm not sure this is worth it. Adding aDeprecationWarning still imposes a cost on users because now they have to change their code to avoid or suppress the warning. The benefit of such a change would still be years in the future, at which point I'd hope thatsys.abi_features would be a better alternative.

I don't feel particularly strongly about this, so if@zooba thinks this is a good approach, then it's fine with me.

AA-Turner reacted with thumbs up emoji

@XuehaiPan
Copy link
ContributorAuthor

The benefit of such a change would still be years in the future, at which point I'd hope thatsys.abi_features would be a better alternative.

Thesys.abi_features alternative does not replace the incoming change ofsys.abiflags and vice versa. Both can benefit the community independently.

The recent update of theaction/setup-python adds3.13t support (release note). I changed the code to determinePYTHON_TAG which is used in the artifact name (e.g.,coverage-${{ env.PYTHON_TAG }}-${{ runner.os }}.xml) inhttps://github.com/metaopt/optree/pull/198/files.

export PYTHON_TAG="$(echo'import sys, sysconfig; print(    "{0.name[0]}p{1.major}{1.minor}{2}".format(      sys.implementation,      sys.version_info,      getattr(sys, "abiflags", "t" if sysconfig.get_config_var("Py_GIL_DISABLED") else ""),    ).lower(),  )'|${{ env.PYTHON }} -)"

This would benefit from a validsys.abiflags on all platforms.

The incomingsys.abi_features would be useful. But in scripting and CIs, a goodsys.abiflags can make the inline code shorter and easier to maintain.

@@ -333,7 +334,12 @@ def get_makefile_filename():
if _PYTHON_BUILD:
return os.path.join(_PROJECT_BASE, "Makefile")

if hasattr(sys, 'abiflags'):
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Are there any details about the existence ofsys.abiflags for cross-compiling for Windows on Ubuntu? I found it might be non-trivial to replace the following with one another:

hasattr(sys,'abiflags')os.name=='nt'# os.name != 'posix'notsys.platform.startswith('win')

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This requires a full-fledged What's New entry + possibly under the incompatible changes / porting to Python 3.14 code or something like that.

Comment on lines +34 to +36
See the notes for :ref:`incoming change to sys.abiflags
<whatsnew314-sys-abiflags-change>` on the *What's New in 3.14*
page for more details.
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The first beta version of Python 3.14 is out. Any comment on this?

@zooba
Copy link
Member

I think we can still apply this to 3.14 during beta, but I'm still not convinced we need to. Thesysconfig variable exists and should be sufficient for those who need build flags, and there are other mechanisms for those who want to know at runtime (mainlysys._is_gil_enabled).

So I still worry that we're effectively adding a new and unspecified API here when we ought to be trying to remove the same API from everywhere else (as in, I don't think POSIX users should be usingsys.abiflags either).

@XuehaiPan
Copy link
ContributorAuthor

XuehaiPan commentedMay 8, 2025
edited
Loading

I think we can still apply this to 3.14 during beta, but I'm still not convinced we need to. The sysconfig variable exists and should be sufficient for those who need build flags
So I still worry that we're effectively adding a new and unspecified API here when we ought to be trying to remove the same API from everywhere else (as in, I don't think POSIX users should be using sys.abiflags either).

Yes, this functionality can be covered by other APIs, such assysconfig.get_config_var("ABIFLAGS") after#131799.

However, as commented in#131799 (comment), variables insysconfig.get_config_vars() are not documented and do not hold forward- and backward-compatibility guarantees. They are also implementation dependent.

The rationale for keeping and makingsys.abiflags generally available:

  1. Forward- and backward-compatibility guarantees.
  2. Keep consistency betweensys.abiflags andsysconfig.get_config_var("ABIFLAGS") on Windows.
  3. Member with static name (sys.abiflags) is easier to inspect than getting value fromdict[str, Any] via strings (sysconfig.get_config_var("ABIFLAGS")).
  4. Make static tools happy, such asmypy.mypy recognizessys.version_info andsys.platform while not acceptingplatform.system().

PS: the incomingsys.abi_features inPEP-780 is targeted to Python 3.14. And it partially resolves (3) and (4). But it has not been implemented yet.

@zooba
Copy link
Member

The rationale for keeping and making sys.abiflags generally available:

  • Forward- and backward-compatibility guarantees.

We can't make guarantees about this API as it stands. It needs a PEP and documentation to properly define it, includingall possible values. Without that, it'll always have no compatibility guarantees.

  • Keep consistency between sys.abiflags and sysconfig.get_config_var("ABIFLAGS") on Windows.

The correct source of the information issysconfig. We don't need consistency, we need people to ignore thesys attribute (which is only there to make the value available insysconfig - it was added before_sysconfig existed).

  • Member with static name (sys.abiflags) is easier to inspect than getting value from dict[str, Any] via strings (sysconfig.get_config_var("ABIFLAGS")).

Perhaps true, but then you have hundreds to move fromsysconfig. Justify why this one is too special.

  • Make static tools happy, such as mypy. mypy recognizes sys.version_info and sys.platform while not accepting platform.system().

It's up to mypy to figure that stuff out. It shouldn't have anything reliant on abiflags anyway, as abiflags don't impact the Python language at all.

I don't think any of these reasons are good justifications.

@XuehaiPan
Copy link
ContributorAuthor

Since#131799 is merged, I would like to close this PR and issue#127405 oncesys.abi_features (PEP-780) gets implemented.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz left review comments

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@FFY00FFY00Awaiting requested review from FFY00FFY00 is a code owner

@colesburycolesburyAwaiting requested review from colesbury

@zoobazoobaAwaiting requested review from zooba

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@XuehaiPan@colesbury@zooba@picnixz@graingert

[8]ページ先頭

©2009-2025 Movatter.jp