Skip to content

Commit

Permalink
Simplify code for pyodide.version field (pyodide#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hood Chatham authored Jan 11, 2021
1 parent 65aa334 commit 9f2ce2b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
17 changes: 0 additions & 17 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@
} \
} while (0)

_Py_IDENTIFIER(__version__);

static int
version_info_init()
{
PyObject* pyodide = PyImport_ImportModule("pyodide");
PyObject* pyodide_version = _PyObject_GetAttrId(pyodide, &PyId___version__);
const char* pyodide_version_utf8 = PyUnicode_AsUTF8(pyodide_version);

EM_ASM({ Module.version = UTF8ToString($0); }, pyodide_version_utf8);

Py_CLEAR(pyodide);
Py_CLEAR(pyodide_version);
return 0;
}

int
main(int argc, char** argv)
{
Expand Down Expand Up @@ -85,7 +69,6 @@ main(int argc, char** argv)
TRY_INIT(python2js);
TRY_INIT(runpython);

TRY_INIT(version_info);
printf("Python initialization complete\n");

emscripten_exit_with_live_runtime();
Expand Down
1 change: 1 addition & 0 deletions src/pyodide.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {

Module.locateFile = (path) => baseURL + path;
Module.postRun = async () => {
Module.version = Module.pyodide_py.__version__;
delete self.Module;
let response = await fetch(`${baseURL}packages.json`);
let json = await response.json();
Expand Down

0 comments on commit 9f2ce2b

Please sign in to comment.