mirror of https://github.com/pyodide/pyodide.git
Expose version information in javascript
This commit is contained in:
parent
d574047a4d
commit
59de8d4a6d
|
@ -8,7 +8,7 @@ git add *
|
||||||
git config --global user.email "deploybot@nowhere.com"
|
git config --global user.email "deploybot@nowhere.com"
|
||||||
git config --global user.name "Deploybot"
|
git config --global user.name "Deploybot"
|
||||||
git commit -m << END
|
git commit -m << END
|
||||||
Deployed from Circle-CI $CIRCLE_BUILD_NUM"
|
Deployed from Circle-CI $CIRCLE_BUILD_NUM
|
||||||
|
|
||||||
Version $(git describe --tags --always)
|
Version $(git describe --tags --always)
|
||||||
END
|
END
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -162,7 +162,8 @@ root/.built: \
|
||||||
cp src/pyodide.py root/lib/python$(PYMINOR)/site-packages
|
cp src/pyodide.py root/lib/python$(PYMINOR)/site-packages
|
||||||
if command -v git > /dev/null 2>&1 \
|
if command -v git > /dev/null 2>&1 \
|
||||||
&& git describe --tags > /dev/null 2>&1; then \
|
&& git describe --tags > /dev/null 2>&1; then \
|
||||||
sed -i "s/__version__ =.*/__version__ = '$(shell git describe --tags)'/g" root/lib/python$(PYMINOR)/site-packages/pyodide.py; \
|
sed -i "s/__version__ =.*/__version__ = '$(shell git describe --tags)'/g" \
|
||||||
|
root/lib/python$(PYMINOR)/site-packages/pyodide.py; \
|
||||||
fi
|
fi
|
||||||
( \
|
( \
|
||||||
cd root/lib/python$(PYMINOR); \
|
cd root/lib/python$(PYMINOR); \
|
||||||
|
|
|
@ -48,7 +48,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
if (js2python_init() || JsImport_init() || JsProxy_init() ||
|
if (js2python_init() || JsImport_init() || JsProxy_init() ||
|
||||||
pyimport_init() || pyproxy_init() || python2js_init() ||
|
pyimport_init() || pyproxy_init() || python2js_init() ||
|
||||||
runpython_init_js() || runpython_init_py()) {
|
runpython_init_js() || runpython_init_py() || runpython_finalize_js()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,3 +68,12 @@ runpython_init_py()
|
||||||
Py_DECREF(d);
|
Py_DECREF(d);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EM_JS(int, runpython_finalize_js, (), {
|
||||||
|
Module.version = function()
|
||||||
|
{
|
||||||
|
Module.runPython("import pyodide");
|
||||||
|
return Module.runPython("pyodide.__version__");
|
||||||
|
};
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
|
@ -10,4 +10,7 @@ runpython_init_js();
|
||||||
int
|
int
|
||||||
runpython_init_py();
|
runpython_init_py();
|
||||||
|
|
||||||
|
int
|
||||||
|
runpython_finalize_js();
|
||||||
|
|
||||||
#endif /* RUNPYTHON_H */
|
#endif /* RUNPYTHON_H */
|
||||||
|
|
|
@ -2,7 +2,6 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,3 +390,19 @@ def test_load_package_after_convert_string(selenium):
|
||||||
selenium.load_package('kiwisolver')
|
selenium.load_package('kiwisolver')
|
||||||
selenium.run(
|
selenium.run(
|
||||||
"import kiwisolver")
|
"import kiwisolver")
|
||||||
|
|
||||||
|
|
||||||
|
def test_version_info(selenium):
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
|
version_py_str = selenium.run("""
|
||||||
|
import pyodide
|
||||||
|
|
||||||
|
pyodide.__version__
|
||||||
|
""")
|
||||||
|
version_py = LooseVersion(version_py_str)
|
||||||
|
assert version_py > LooseVersion('0.0.1')
|
||||||
|
|
||||||
|
version_js_str = selenium.run_js("return pyodide.version()")
|
||||||
|
version_js = LooseVersion(version_js_str)
|
||||||
|
assert version_py == version_js
|
||||||
|
|
Loading…
Reference in New Issue