-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Modify Emscripten support to use ES6 modules.
- Loading branch information
Showing
6 changed files
with
60 additions
and
30 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Build/2024-11-20-17-12-40.gh-issue-126898.I2zILt.rst
This file contains 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 @@ | ||
The Emscripten build of Python is now based on ES6 modules. |
This file contains 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 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,30 @@ | ||
import EmscriptenModule from "./python.mjs"; | ||
import { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
if (process?.versions?.node) { | ||
const nodeVersion = Number(process.versions.node.split(".", 1)[0]); | ||
if (nodeVersion < 18) { | ||
process.stderr.write( | ||
`Node version must be >= 18, got version ${process.version}\n`, | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
const settings = { | ||
preRun(Module) { | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
Module.FS.mkdirTree("/lib/"); | ||
Module.FS.mount(Module.FS.filesystems.NODEFS, { root: __dirname + "/lib/" }, "/lib/"); | ||
}, | ||
// The first three arguments are: "node", path to this file, path to | ||
// python.sh. After that come the arguments the user passed to python.sh. | ||
arguments: process.argv.slice(3), | ||
// Ensure that sys.executable, sys._base_executable, etc point to python.sh | ||
// not to this file. To properly handle symlinks, python.sh needs to compute | ||
// its own path. | ||
thisProgram: process.argv[2], | ||
}; | ||
|
||
await EmscriptenModule(settings); |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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