Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish out of tree build system (except xbuildenv deploy) (#2823)
This completes the out of tree build CLI. This PR is paired up with: numpy/numpy#21895 I have also successfully built scikit-learn, statsmodels, pandas, and astropy with this. The last thing we need to do after this is set up deployment of the cross build environment. We can deploy one version to s3 for each tagged commit. I will do that in a separate PR after this is merged.
- Loading branch information
Showing
7 changed files
with
134 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import argparse | ||
import os | ||
from pathlib import Path | ||
|
||
from . import build | ||
|
||
|
||
def ensure_env_installed(env: Path) -> None: | ||
if env.exists(): | ||
return | ||
from ..install_xbuildenv import download_xbuild_env, install_xbuild_env | ||
|
||
version = "2" | ||
download_xbuild_env(version, env) | ||
install_xbuild_env(env) | ||
|
||
|
||
def main(): | ||
main_parser = argparse.ArgumentParser(prog="pywasmbuild") | ||
main_parser.description = "Tools for creating Python extension modules for the wasm32-unknown-emscripten platform" | ||
subparsers = main_parser.add_subparsers(help="action") | ||
for module in [build]: | ||
modname = module.__name__.rpartition(".")[-1] | ||
parser = module.make_parser(subparsers.add_parser(modname)) | ||
parser.set_defaults(func=module.main) | ||
|
||
env = Path(".pyodide-xbuildenv") | ||
os.environ["PYODIDE_ROOT"] = str(env / "xbuildenv/pyodide-root") | ||
ensure_env_installed(env) | ||
|
||
args = main_parser.parse_args() | ||
if hasattr(args, "func"): | ||
# run the selected action | ||
args.func(args) | ||
else: | ||
main_parser.print_help() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import argparse | ||
import os | ||
|
||
from .. import common, pypabuild, pywasmcross | ||
|
||
|
||
def run(exports, args): | ||
cflags = common.get_make_flag("SIDE_MODULE_CFLAGS") | ||
cflags += f" {os.environ.get('CFLAGS', '')}" | ||
cxxflags = common.get_make_flag("SIDE_MODULE_CXXFLAGS") | ||
cxxflags += f" {os.environ.get('CXXFLAGS', '')}" | ||
ldflags = common.get_make_flag("SIDE_MODULE_LDFLAGS") | ||
ldflags += f" {os.environ.get('LDFLAGS', '')}" | ||
build_env_ctx = pywasmcross.get_build_env( | ||
env=os.environ.copy(), | ||
pkgname="", | ||
cflags=cflags, | ||
cxxflags=cxxflags, | ||
ldflags=ldflags, | ||
target_install_dir="", | ||
exports=exports, | ||
) | ||
|
||
with build_env_ctx as env: | ||
pypabuild.build(env, " ".join(args)) | ||
|
||
|
||
def main(parser_args: argparse.Namespace) -> None: | ||
run(parser_args.exports, parser_args.backend_args) | ||
|
||
|
||
def make_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: | ||
parser.description = "Use pypa/build to build a Python package." | ||
parser.add_argument( | ||
"--exports", | ||
choices=["pyinit", "requested", "whole_archive"], | ||
default="requested", | ||
help="Which symbols should be exported when linking .so files?", | ||
) | ||
parser.add_argument( | ||
"backend_args", | ||
metavar="args", | ||
type=str, | ||
nargs=argparse.REMAINDER, | ||
help="Arguments to pass on to the backend", | ||
) | ||
return parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters