-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
GH-143941: Move WASI-related files to Platforms/WASI #143942
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
Open
brettcannon
wants to merge
9
commits into
python:main
Choose a base branch
from
brettcannon:platforms-dir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+669
−599
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c791d02
GH-143941: Move WASI-related files to Platforms/WASI
brettcannon b0bd6b3
Update .github/CODEOWNERS
brettcannon f07e6f1
Change what directory is checked for WASI changes
brettcannon d3c26ec
Add some reST to the news entry
brettcannon 0c8eb53
Update the comment left in Setup.local
brettcannon cc2a6b5
Merge branch 'platforms-dir' of https://github.com/brettcannon/cpytho…
brettcannon d142b7e
Merge branch 'main' into platforms-dir
brettcannon e61c1b0
Drop outdated comment
brettcannon ad62e6e
Merge branch 'platforms-dir' of https://github.com/brettcannon/cpytho…
brettcannon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Build/2026-01-16-14-27-53.gh-issue-143941.TiaE-3.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Move WASI-related files to :file:`Platforms/WASI`. Along the way, leave a | ||
| deprecated Tools/wasm/wasi/__main__.py behind for backwards-compatibility. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| extend = "../../.ruff.toml" # Inherit the project-wide settings | ||
|
|
||
| [format] | ||
| preview = true | ||
| docstring-code-format = true | ||
|
|
||
| [lint] | ||
| select = [ | ||
| "C4", # flake8-comprehensions | ||
| "E", # pycodestyle | ||
| "F", # pyflakes | ||
| "I", # isort | ||
| "ISC", # flake8-implicit-str-concat | ||
| "LOG", # flake8-logging | ||
| "PGH", # pygrep-hooks | ||
| "PT", # flake8-pytest-style | ||
| "PYI", # flake8-pyi | ||
| "RUF100", # Ban unused `# noqa` comments | ||
| "UP", # pyupgrade | ||
| "W", # pycodestyle | ||
| "YTT", # flake8-2020 | ||
| ] | ||
| ignore = [ | ||
| "E501", # Line too long | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Python WASI (wasm32-wasi) build | ||
|
|
||
| **WASI support is [tier 2](https://peps.python.org/pep-0011/#tier-2).** | ||
|
|
||
| This directory contains configuration and helpers to facilitate cross | ||
| compilation of CPython to WebAssembly (WASM) using WASI. WASI builds | ||
| use WASM runtimes such as [wasmtime](https://wasmtime.dev/). | ||
|
|
||
| **NOTE**: If you are looking for general information about WebAssembly that is | ||
| not directly related to CPython, please see https://github.com/psf/webassembly. | ||
|
|
||
| ## Build | ||
|
|
||
| See [the devguide on how to build and run for WASI](https://devguide.python.org/getting-started/setup-building/#wasi). | ||
|
|
||
| ## Detecting WASI builds | ||
|
|
||
| ### Python code | ||
|
|
||
| ```python | ||
| import os, sys | ||
|
|
||
| if sys.platform == "wasi": | ||
| # Python on WASI | ||
| ... | ||
|
|
||
| if os.name == "posix": | ||
| # WASM platforms identify as POSIX-like. | ||
| # Windows does not provide os.uname(). | ||
| machine = os.uname().machine | ||
| if machine.startswith("wasm"): | ||
| # WebAssembly (wasm32, wasm64 potentially in the future) | ||
| ``` | ||
|
|
||
| ```python | ||
| >>> import os, sys | ||
| >>> os.uname() | ||
| posix.uname_result( | ||
| sysname='wasi', | ||
| nodename='(none)', | ||
| release='0.0.0', | ||
| version='0.0.0', | ||
| machine='wasm32' | ||
| ) | ||
| >>> os.name | ||
| 'posix' | ||
| >>> sys.platform | ||
| 'wasi' | ||
| ``` | ||
|
|
||
| ### C code | ||
|
|
||
| WASI SDK defines several built-in macros. You can dump a full list of built-ins | ||
| with ``/path/to/wasi-sdk/bin/clang -dM -E - < /dev/null``. | ||
|
|
||
| * WebAssembly ``__wasm__`` (also ``__wasm``) | ||
| * wasm32 ``__wasm32__`` (also ``__wasm32``) | ||
| * wasm64 ``__wasm64__`` | ||
| * WASI ``__wasi__`` |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Probably worth highlighting too?
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.
See #143942 (comment) where this was proposed and I took Zach's advice not to make the change.
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.
There's syntax to keep the formatting but suppress the link; maybe
?
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.
:file:doesn’t create links, no? You are thinking of:source:.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.
@zware @brettcannon: @StanFromIreland is correct — the
:file:role in Sphinx does not produce a clickable link. It looks like regular inline<code>with nothing special.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.
Ah, whoops. In that case, we do want the
:file:role to avoid issues from the underscores.