GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-119132: Update sys.version to identify free-threaded or not. by corona10 · Pull Request #119134 · python/cpython

Conversation

@corona10

@corona10 corona10 commented May 17, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Python -VV should display whether the build is default build or free-threading. #119132

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk reacted with thumbs up emoji stonebig reacted with heart emoji
All reactions
  • 👍 1 reaction
  • ❤️ 1 reaction
@corona10
pythongh-119132: Update buildinfo to identify free-threaded or not.
dd95b0e
@corona10
corona10 requested review from hugovk and vstinner May 17, 2024 23:54
@bedevere-app bedevere-app Bot added the awaiting core review label May 17, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 17, 2024
Python -VV should display whether the build is default build or free-threading. #119132
Closed
@corona10 corona10 added topic-free-threading and removed awaiting core review labels May 17, 2024
@corona10 corona10 changed the title gh-119132: Update buildinfo to identify free-threaded or not. [WIP] gh-119132: Update buildinfo to identify free-threaded or not. May 17, 2024
@corona10
corona10 marked this pull request as draft May 18, 2024 00:07
@nineteendo

nineteendo commented May 18, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Could we maybe leave out "default" for the normal build? It doesn't really add value:

Python 3.14.0a0 (heads/main-dirty:31a28cbae0, May 17 2024, 17:30:32) [GCC 14.1.1 20240507 (Red Hat 14.1.1-1)]
Python 3.14.0a0 (heads/main-dirty:31a28cbae0, May 17 2024, 17:30:32, free-threading) [GCC 14.1.1 20240507 (Red Hat 14.1.1-1)]

The tests on GitHub don't include "(default)" either. Maybe even like this:

Python 3.14.0a0 (heads/main-dirty:31a28cbae0, May 17 2024, 17:30:32) [GCC 14.1.1 20240507 (Red Hat 14.1.1-1)]
Python 3.14.0a0 (free-threading) (heads/main-dirty:31a28cbae0, May 17 2024, 17:30:32) [GCC 14.1.1 20240507 (Red Hat 14.1.1-1)]

This could even work for --version, but some people might rely on the format:

Python 3.14.0a0
Python 3.14.0a0 (free-threading)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nineteendo

nineteendo commented May 18, 2024

Copy link
Copy Markdown
Contributor

You still need to update this:

cpython/Lib/platform.py

Lines 1156 to 1161 in 81c3130

sys_version_parser = re.compile(
r'([\w.+]+)\s*' # "version<space>"
r'\(#?([^,]+)' # "(#buildno"
r'(?:,\s*([\w ]*)' # ", builddate"
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Update test
04f5a79
@nineteendo

nineteendo commented May 18, 2024

Copy link
Copy Markdown
Contributor

Currently this test is failing:

cpython/Lib/test/test_platform.py

Line 129 in 81c3130

def test_sys_version(self):

Do you have an opinion on not including "default"?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Only for free-threading
5034205
@corona10

corona10 commented May 18, 2024

Copy link
Copy Markdown
Member Author

Do you have an opinion on not including "default"?

Hey, I am under testing. Would you like to leave a comment once I convert the PR into the official PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nineteendo

nineteendo commented May 18, 2024

Copy link
Copy Markdown
Contributor

Old regex:

([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?\)\s*\[([^\]]+)\]?

New regex:

([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)(?:,\s*(free-threading))?\)*\s*\[([^\]]+)\]?

Unmatched string:

2.4.3 (truncation) 
[GCC]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nineteendo
nineteendo reviewed May 18, 2024
View reviewed changes
Comment thread Lib/platform.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10 @nineteendo
Update Lib/platform.py
f135b42
Co-authored-by: Nice Zombies <[email protected]>
nineteendo
nineteendo reviewed May 18, 2024
View reviewed changes
Comment thread Lib/platform.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10 @nineteendo
Update Lib/platform.py
94cbf8d
Co-authored-by: Nice Zombies <[email protected]>
@corona10

corona10 commented May 18, 2024

Copy link
Copy Markdown
Member Author

@nineteendo Thanks for the comment

Still issue (nah I am really bad at regex)

- ('CPython', '2.4.3', '', '', 'truncation) \n', '', 'GCC')
?                                         ----

+ ('CPython', '2.4.3', '', '', 'truncation', '', 'GCC')
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
corona10 force-pushed the gh-119132 branch from 52df2d0 to 94cbf8d Compare May 18, 2024 10:17
@vstinner

vstinner commented May 18, 2024

Copy link
Copy Markdown
Member

I proposed a similar idea last August, but it was rejected at that time: #108239

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented May 18, 2024

Copy link
Copy Markdown
Member

I suggest to mention sys.version in the PR title.

The "(...)" part of sys.version is the Git information, I would prefer to not touch it.

If we change sys.version, I would prefer to "add a new field" in sys.version. For example, add free-threading or [free-threading] after the version. Example:

Python 3.14.0a0 free-threading (heads/main:81c3130c51, May 18 2024, 07:29:44) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux

The drawback of changing sys.version is that it breaks tooling parsing it in a strict way.

corona10 and nineteendo reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10

corona10 commented May 18, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Then we need to discuss with @hugovk

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nineteendo

nineteendo commented May 18, 2024

Copy link
Copy Markdown
Contributor

You accidentally added * after \):

-([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?(?:,\s*(free-threading))?\)*\s*\[([^\]]+)\]?
+([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?(?:,\s*(free-threading))?\)\s*\[([^\]]+)\]?

But I would prefer a new field as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead reviewed May 18, 2024
View reviewed changes
Comment thread Lib/platform.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead reviewed May 18, 2024
View reviewed changes
Comment thread Modules/getbuildinfo.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Address code review
e2d60ba
@corona10 corona10 changed the title [WIP] gh-119132: Update buildinfo to identify free-threaded or not. gh-119132: Update sys.version to identify free-threaded or not. May 18, 2024
@corona10

corona10 commented May 18, 2024

Copy link
Copy Markdown
Member Author

@Yhg1s What do you think about backporting it into the 3.13 since it will help the free-threading ecosystem?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
nit
f54cef4
gpshead
gpshead reviewed May 18, 2024
View reviewed changes
Comment thread Lib/platform.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Address code review
e0b3370
gpshead
gpshead reviewed May 18, 2024
View reviewed changes
Comment thread Python/getversion.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Address code review
c3fd105
gpshead
gpshead approved these changes May 18, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 18, 2024
hugovk
hugovk approved these changes May 18, 2024
View reviewed changes
vstinner
vstinner reviewed May 18, 2024
View reviewed changes
Comment thread Python/getversion.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@corona10
Increase the buffer
a29a17d
erlend-aasland
erlend-aasland approved these changes May 18, 2024
View reviewed changes
vstinner
vstinner reviewed May 18, 2024
View reviewed changes
Comment thread Lib/platform.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed May 18, 2024
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

LGTM, but see my comment on regex.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@corona10 @vstinner
Update Lib/platform.py
267a0fd
Co-authored-by: Victor Stinner <[email protected]>
@corona10 corona10 added the needs backport to 3.13 only security fixes label May 18, 2024
@corona10
corona10 enabled auto-merge (squash) May 18, 2024 19:20
@corona10
corona10 merged commit c141d43 into python:main May 18, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label May 18, 2024
@miss-islington-app

miss-islington-app Bot commented May 18, 2024

Copy link
Copy Markdown

Thanks @corona10 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2024
@corona10 @miss-islington
pythongh-119132: Update sys.version to identify free-threaded or not. (…
82a9119
…pythongh-119134)

(cherry picked from commit c141d43)

Co-authored-by: Donghee Na <[email protected]>
@bedevere-app

bedevere-app Bot commented May 18, 2024

Copy link
Copy Markdown

GH-119153 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 18, 2024
corona10 added a commit that referenced this pull request May 18, 2024
@miss-islington @corona10
[3.13] gh-119132: Update sys.version to identify free-threaded or not. (
ec88e9f
gh-119134) (#119153)

gh-119132: Update sys.version to identify free-threaded or not. (gh-119134)
(cherry picked from commit c141d43)

Co-authored-by: Donghee Na <[email protected]>
@smontanaro

smontanaro commented May 19, 2024

Copy link
Copy Markdown
Contributor

Sorry, I haven't been paying close attention, but was there a decision not to tweak sys.version_info as well?

>>> sys.version
'3.14.0a0 experimental free-threading build (heads/main:697465ff88e, May 19 2024, 07:40:21) [Clang 15.0.0 (clang-1500.3.9.4)]'
>>> sys.version_info
sys.version_info(major=3, minor=14, micro=0, releaselevel='alpha', serial=0)

It seems that since it's a named tuple there'd be little problem adding a new field which distinguishes the two builds. Something like:

>>> sys.version_info
sys.version_info(major=3, minor=14, micro=0, releaselevel='alpha', serial=0, free_threading=True)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead

gpshead commented May 19, 2024

Copy link
Copy Markdown
Member

was there a decision not to tweak sys.version_info as well?

build information is not part of version_info. the version string is meant for humans and includes other detailed things that are also not in version_info such as compiler details.

there's the https://docs.python.org/3.13/library/sys.html#sys._is_gil_enabled may-change-in-the-future API for people wanting to know the current status of the GIL regardless of build type.

nineteendo and erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@smontanaro

smontanaro commented May 19, 2024

Copy link
Copy Markdown
Contributor

Thanks. Just checking. As long as there is somewhere to query the status at run-time without parsing a human-readable string.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@corona10 @estyxx
pythongh-119132: Update sys.version to identify free-threaded or not. (…
6d5c2de
…pythongh-119134)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes
@vstinner vstinner vstinner left review comments
@hugovk hugovk hugovk approved these changes
@erlend-aasland erlend-aasland erlend-aasland approved these changes
+1 more reviewer
@nineteendo nineteendo nineteendo left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@corona10 @nineteendo @vstinner @smontanaro @gpshead @hugovk @erlend-aasland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.