Skip to content

Python 3 is the default nowadays #1243

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

Closed
wants to merge 1 commit into from

Conversation

DimitriPapadopoulos
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos commented May 4, 2025

No need to explicitly require Python 3.

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

I might be misunderstanding your PR's intent here, but this option doesn't have to do with Python 3 being the default or not: the reason we set 3.x is because setup-python strongly encourages the user to set some version; without an explicit version the runner's system Python is used, and that can be unpredictable/unreliable across runner changes.

TL;DR: This setting doesn't have anything to do with Python 2 vs. 3; it's here to make GitHub's CI/CD runners behave consistently. Removing this setting would expose us to default behavior that would be difficult to debug/diagnose since it only happens remotely.

@woodruffw
Copy link
Member

Closing per above.

@woodruffw woodruffw closed this May 4, 2025
@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented May 4, 2025

@woodruffw Precisely, 3.x is not "some version". I've read the setup-python documentation and haven't found anything to support the need for 3.x:
https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-the-python-version-input

Am I missing information that is absent from the setup-python documentation?

@woodruffw
Copy link
Member

From the setup-python README:

The python-version input is optional. If not supplied, the action will try to resolve the version from the default .python-version file. If the .python-version file doesn't exist Python or PyPy version from the PATH will be used. The default version of Python or PyPy in PATH varies between runners and can be changed unexpectedly so we recommend always setting Python version explicitly using the python-version or python-version-file inputs.

twine doesn't provide a .python-version file, so the fallback behavior applies. In practice that means 3.8 or 3.9 (both EOL) on most runners. Either way, setting 3.x means that we get the latest stable Python 3.x release, which is what we want for the release workflow.

@DimitriPapadopoulos
Copy link
Contributor Author

I see, thank you. The documentation is not clear enough about 3.x pulling the latest release of Python 3. I'll try to suggest an improvement.

@woodruffw
Copy link
Member

The documentation is not clear enough about 3.x pulling the latest release of Python 3

I agree it could be clearer, although it is mentioned under "x-ranges" in the docs you linked.

(More generally, IMO it's an anti-feature that setup-python uses the system Python at all. But that's unfortunately probably pretty baked into their assumptions, I would guess.)

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.

2 participants