Skip to content

Commit c1bcd07

Browse files
authored
Add core packages (#6)
1 parent d8a7864 commit c1bcd07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3252
-21
lines changed

.github/workflows/build.yml

+22-17
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,36 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
17-
- uses: actions/setup-python@v4
17+
18+
- uses: conda-incubator/setup-miniconda@v2
1819
with:
19-
python-version: "3.11"
20+
activate-environment: pyodide-env
21+
environment-file: environment.yml
22+
channels: conda-forge
23+
2024
- name: Install latest pyodide-build and build dependencies
25+
shell: bash -l {0}
2126
run : |
22-
pip install git+https://github.com/pyodide/pyodide.git@main#subdirectory=pyodide-build
23-
pip install setuptools --upgrade
24-
27+
which python
28+
python -m pip install git+https://github.com/pyodide/pyodide.git@main#subdirectory=pyodide-build
2529
pyodide xbuildenv install --download --url http://pyodide-cache.s3-website-us-east-1.amazonaws.com/xbuildenv/dev/xbuildenv.tar.bz2
2630
27-
sudo apt update
28-
sudo apt install gfortran f2c
29-
3031
- name: Check emscripten version
32+
shell: bash -l {0}
3133
run: |
3234
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
35+
3336
- uses: mymindstorm/setup-emsdk@v11
3437
with:
3538
version: ${{ env.EMSCRIPTEN_VERSION }}
3639

3740
- name: Calculate recipes to build (pull_request)
3841
if: github.event_name == 'pull_request'
3942
id: calculate_recipes_pr
43+
shell: bash -l {0}
4044
run: |
41-
CHANGED_RECIPES=$(python ./tools/calc_diff.py \
42-
--base ${{ github.base_ref }} \
45+
export CHANGED_RECIPES=$(python ./tools/calc_diff.py \
46+
--base origin/${{ github.base_ref }} \
4347
--target ${{ github.head_ref }})
4448
4549
# If there are no changed recipes, we build only core packages sets
@@ -50,11 +54,13 @@ jobs:
5054
fi
5155
5256
- name: Build recipes (full)
57+
shell: bash -l {0}
5358
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[full build]') }}
5459
run: |
5560
pyodide build-recipes "*" --install --install-dir=./repodata
5661
5762
- name: Build recipes (changed only)
63+
shell: bash -l {0}
5864
if: github.event_name == 'pull_request' && !contains(github.event.head_commit.message, '[full build]')
5965
run: |
6066
pyodide build-recipes ${{ steps.calculate_recipes_pr.outputs.recipes }} --install --install-dir=./repodata
@@ -89,11 +95,14 @@ jobs:
8995
steps:
9096
- uses: actions/checkout@v3
9197

92-
- uses: actions/setup-python@v4
98+
- uses: conda-incubator/setup-miniconda@v2
9399
with:
94-
python-version: "3.11"
100+
activate-environment: pyodide-env
101+
environment-file: environment.yml
102+
channels: conda-forge
95103

96104
- name: Download latest Pyodide
105+
shell: bash -l {0}
97106
run: |
98107
wget http://pyodide-cache.s3-website-us-east-1.amazonaws.com/xbuildenv/dev/pyodide-core.tar.bz2
99108
tar -xvf pyodide-core.tar.bz2
@@ -105,11 +114,6 @@ jobs:
105114
browser: ${{ matrix.test-config.runtime }}
106115
browser-version: ${{ matrix.test-config.runtime-version }}
107116

108-
- name: Install requirements
109-
shell: bash -l {0}
110-
run: |
111-
python3 -m pip install pytest pytest-pyodide pytest-httpserver
112-
113117
- name: Download build artifact
114118
uses: actions/download-artifact@v2
115119
with:
@@ -121,6 +125,7 @@ jobs:
121125
cp ./repodata/* ./dist/
122126
123127
- name: Run tests
128+
shell: bash -l {0}
124129
run: |
125130
# FIXME: skip webworker tests
126131
pytest -v \

environment.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: pyodide-env
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.11
6+
- nodejs
7+
- ccache
8+
- f2c
9+
- pkg-config
10+
- swig
11+
- make
12+
- cmake
13+
- pkg-config
14+
- texinfo
15+
- autoconf
16+
- automake
17+
- libtool
18+
- wget
19+
- setuptools
20+
- pip:
21+
- pytest
22+
- pytest-pyodide
23+
- pytest-httpserver

packages/Jinja2/meta.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package:
2+
name: Jinja2
3+
version: 3.1.2
4+
tag:
5+
- core
6+
- min-scipy-stack
7+
top-level:
8+
- jinja2
9+
requirements:
10+
run:
11+
- MarkupSafe
12+
source:
13+
sha256: 6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61
14+
url: https://files.pythonhosted.org/packages/bc/c3/f068337a370801f372f2f8f6bad74a5c140f6fda3d9de154052708dd3c65/Jinja2-3.1.2-py3-none-any.whl
15+
about:
16+
home: https://palletsprojects.com/p/jinja/
17+
PyPI: https://pypi.org/project/Jinja2
18+
summary: A very fast and expressive template engine.
19+
license: BSD-3-Clause

packages/Jinja2/test_jinja2.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from pytest_pyodide import run_in_pyodide
2+
3+
4+
@run_in_pyodide(packages=["Jinja2"])
5+
def test_jinja2(selenium):
6+
import jinja2
7+
8+
template = jinja2.Template("Hello {{ name }}!")
9+
content = template.render(name="Zach")
10+
assert content == "Hello Zach!"

packages/MarkupSafe/meta.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package:
2+
name: MarkupSafe
3+
version: 2.1.3
4+
top-level:
5+
- markupsafe
6+
source:
7+
sha256: af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad
8+
url: https://files.pythonhosted.org/packages/6d/7c/59a3248f411813f8ccba92a55feaac4bf360d29e2ff05ee7d8e1ef2d7dbf/MarkupSafe-2.1.3.tar.gz
9+
about:
10+
home: https://palletsprojects.com/p/markupsafe/
11+
PyPI: https://pypi.org/project/MarkupSafe
12+
summary: Safely add untrusted strings to HTML/XML markup.
13+
license: BSD-3-Clause

packages/atomicwrites/meta.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package:
2+
name: atomicwrites
3+
version: 1.4.1
4+
top-level:
5+
- atomicwrites
6+
source:
7+
sha256: 81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11
8+
url: https://files.pythonhosted.org/packages/87/c6/53da25344e3e3a9c01095a89f16dbcda021c609ddb42dd6d7c0528236fb2/atomicwrites-1.4.1.tar.gz
9+
about:
10+
home: https://github.com/untitaker/python-atomicwrites
11+
PyPI: https://pypi.org/project/atomicwrites
12+
summary: Atomic file writes.
13+
license: MIT

packages/attrs/meta.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package:
2+
name: attrs
3+
version: 23.1.0
4+
top-level:
5+
- attr
6+
- attrs
7+
source:
8+
sha256: 1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04
9+
url: https://files.pythonhosted.org/packages/f0/eb/fcb708c7bf5056045e9e98f62b93bd7467eb718b0202e7698eb11d66416c/attrs-23.1.0-py3-none-any.whl
10+
requirements:
11+
run:
12+
- six
13+
about:
14+
home: https://www.attrs.org/
15+
PyPI: https://pypi.org/project/attrs
16+
summary: Classes Without Boilerplate
17+
license: MIT
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package:
2+
name: cpp-exceptions-test
3+
version: "0.1"
4+
tag:
5+
- core
6+
- pyodide.test
7+
- library
8+
source:
9+
path: src
10+
build:
11+
type: shared_library
12+
script: |
13+
em++ -c throw.cpp -o throw.o ${SIDE_MODULE_CFLAGS} -fexceptions -I${PYTHONINCLUDE} -flto -fno-lto
14+
em++ -c catch.cpp -o catch.o ${SIDE_MODULE_CFLAGS} -fexceptions -I${PYTHONINCLUDE} -flto -fno-lto
15+
em++ throw.o ${SIDE_MODULE_LDFLAGS} -o ${DISTDIR}/cpp-exceptions-test-throw.so -fexceptions
16+
em++ catch.o ${SIDE_MODULE_LDFLAGS} -o ${DISTDIR}/cpp-exceptions-test-catch.so -fexceptions
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <exception>
2+
using namespace std;
3+
#include <Python.h>
4+
#include <setjmp.h>
5+
#include <stdexcept>
6+
#include <stdio.h>
7+
8+
extern "C" char*
9+
throw_exc(int x);
10+
11+
extern "C" int
12+
call_pyobj(PyObject* x);
13+
14+
extern "C" char*
15+
catch_exc(int x)
16+
{
17+
char* msg;
18+
try {
19+
char* res = throw_exc(x);
20+
asprintf(&msg, "result was: %s", res);
21+
} catch (int param) {
22+
asprintf(&msg, "caught int %d", param);
23+
} catch (char param) {
24+
asprintf(&msg, "caught char %d", param);
25+
} catch (runtime_error& e) {
26+
asprintf(&msg, "caught runtime_error %s", e.what());
27+
} catch (...) {
28+
asprintf(&msg, "caught ????");
29+
}
30+
return msg;
31+
}
32+
33+
extern "C" char*
34+
catch_call_pyobj(PyObject* x)
35+
{
36+
char* msg;
37+
try {
38+
int res = call_pyobj(x);
39+
asprintf(&msg, "result was: %d", res);
40+
} catch (int param) {
41+
asprintf(&msg, "caught int %d", param);
42+
} catch (char param) {
43+
asprintf(&msg, "caught char %d", param);
44+
} catch (runtime_error& e) {
45+
asprintf(&msg, "caught runtime_error %s", e.what());
46+
} catch (...) {
47+
asprintf(&msg, "caught ????");
48+
}
49+
return msg;
50+
}
51+
52+
jmp_buf my_jump_buffer;
53+
void
54+
longjmp_func(int status);
55+
56+
extern "C" int
57+
set_jmp_func()
58+
{
59+
int status = setjmp(my_jump_buffer);
60+
if (status == 0) {
61+
longjmp_func(4);
62+
}
63+
return status;
64+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <Python.h>
2+
#include <exception>
3+
#include <stdexcept>
4+
5+
#include <setjmp.h>
6+
#include <stdnoreturn.h>
7+
8+
jmp_buf my_jump_buffer;
9+
using namespace std;
10+
11+
class myexception : public exception
12+
{
13+
virtual const char* what() const throw() { return "My exception happened"; }
14+
} myex;
15+
16+
extern "C" char*
17+
throw_exc(int x)
18+
{
19+
if (x == 1) {
20+
throw 1000;
21+
} else if (x == 2) {
22+
throw 'c';
23+
} else if (x == 3) {
24+
throw runtime_error("abc");
25+
} else if (x == 4) {
26+
throw myex;
27+
} else {
28+
throw "abc";
29+
}
30+
}
31+
32+
extern "C" int
33+
call_pyobj(PyObject* x)
34+
{
35+
PyObject* result = PyObject_CallNoArgs(x);
36+
int r = PyLong_AsLong(result);
37+
Py_DECREF(result);
38+
return r;
39+
}
40+
41+
noreturn void
42+
longjmp_func(int status)
43+
{
44+
longjmp(my_jump_buffer, status + 1); // will return status+1 out of setjmp
45+
}

0 commit comments

Comments
 (0)