pyodide/pyodide_build/common.py

51 lines
1.4 KiB
Python
Raw Normal View History

2018-08-03 16:48:22 +00:00
from pathlib import Path
from typing import Optional, Set
2018-06-20 19:05:13 +00:00
ROOTDIR = Path(__file__).parents[1].resolve()
TOOLSDIR = ROOTDIR / "tools"
PACKAGERDIR = ROOTDIR / "emsdk" / "emsdk" / "fastcomp" / "emscripten" / "tools"
TARGETPYTHON = ROOTDIR / "cpython" / "installs" / "python-3.8.2"
# Leading space so that argparse doesn't think this is a flag
DEFAULTCFLAGS = " -fPIC"
# fmt: off
DEFAULTLDFLAGS = " ".join(
[
"-O2",
"-Werror",
"-s", "EMULATE_FUNCTION_POINTER_CASTS=1",
"-s", "SIDE_MODULE=1",
"-s", "WASM=1",
"-s", "BINARYEN_TRAP_MODE='clamp'",
"--memory-init-file", "0",
"-s", "LINKABLE=1",
"-s", "EXPORT_ALL=1",
]
)
# fmt: on
2018-06-20 18:54:47 +00:00
def parse_package(package):
2018-06-22 18:49:52 +00:00
# Import yaml here because pywasmcross needs to run in the built native
# Python, which won't have PyYAML
import yaml
2018-06-20 18:54:47 +00:00
# TODO: Validate against a schema
with open(package) as fd:
return yaml.safe_load(fd)
def _parse_package_subset(query: Optional[str]) -> Optional[Set[str]]:
"""Parse the list of packages specified with PYODIDE_PACKAGES env var.
2020-05-08 23:46:59 +00:00
Also add the list of mandatory packages: ['micropip', 'distlib']
Returns:
a set of package names to build or None.
"""
2020-05-09 10:32:10 +00:00
if query is None:
return None
packages = query.split(",")
packages = [el.strip() for el in packages]
packages = ["micropip", "distlib"] + packages
return set(packages)