Merge pull request #166 from rth/versioning

Add version information
This commit is contained in:
Michael Droettboom 2018-09-14 15:57:58 -04:00 committed by GitHub
commit 2ca008bb24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 6 deletions

View File

@ -77,6 +77,9 @@ jobs:
- ./pyodide-env - ./pyodide-env
- ./firefox - ./firefox
- store_artifacts:
path: /home/circleci/repo/build/
test-firefox: test-firefox:
<<: *defaults <<: *defaults
steps: steps:
@ -111,9 +114,6 @@ jobs:
export PATH=$PWD/firefox:$PATH export PATH=$PWD/firefox:$PATH
pytest test -v -k chrome pytest test -v -k chrome
- store_artifacts:
path: /home/circleci/repo/build/
deploy: deploy:
machine: machine:
enabled: true enabled: true

View File

@ -7,7 +7,11 @@ git checkout --orphan tmp
git add * 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 "Deployed from Circle-CI $CIRCLE_BUILD_NUM" git commit -m << END
Deployed from Circle-CI $CIRCLE_BUILD_NUM
Version $(git describe --tags --always)
END
git checkout master git checkout master
git reset --hard tmp git reset --hard tmp
git push origin -f master git push origin -f master

View File

@ -160,6 +160,11 @@ root/.built: \
cp src/_testcapi.py root/lib/python$(PYMINOR) cp src/_testcapi.py root/lib/python$(PYMINOR)
cp src/pystone.py root/lib/python$(PYMINOR) cp src/pystone.py root/lib/python$(PYMINOR)
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 \
&& 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; \
fi
( \ ( \
cd root/lib/python$(PYMINOR); \ cd root/lib/python$(PYMINOR); \
rm -fr `cat ../../../remove_modules.txt`; \ rm -fr `cat ../../../remove_modules.txt`; \

View File

@ -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;
} }

View File

@ -7,6 +7,8 @@ from js import XMLHttpRequest
import ast import ast
import io import io
__version__ = '0.1.0'
def open_url(url): def open_url(url):
""" """

View File

@ -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;
});

View File

@ -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 */

View File

@ -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