forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-126898 Switch to exporting an es6 module and using a node_en…
…try script
- Loading branch information
Showing
5 changed files
with
59 additions
and
30 deletions.
There are no files selected for viewing
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