1- #!/usr/bin/env python3
2-
3- __lazy_modules__ = ["_build"]
1+ __lazy_modules__ = [
2+ "argparse",
3+ "os",
4+ "pathlib",
5+ "_build",
6+ "_package",
7+ "_shared",
8+ ]
49
510import argparse
611import os
712import pathlib
813
914import _build
10-
11- HERE = pathlib.Path(__file__).parent
15+ import _package
16+ import _shared
1217
1318
1419def main():
@@ -27,6 +32,7 @@ def main():
2732 # may want to use them.
2833 "--config {WASMTIME_CONFIG_PATH}"
2934 )
35+ context = _shared.Context()
3036
3137 parser = argparse.ArgumentParser()
3238 subcommands = parser.add_subparsers(dest="subcommand")
@@ -59,6 +65,9 @@ def main():
5965 pythoninfo_host = subcommands.add_parser(
6066 "pythoninfo-host", help="Display build info of the host/WASI Python"
6167 )
68+ package = subcommands.add_parser(
69+ "package", help="Package the host/WASI Python into an archive"
70+ )
6271 subcommands.add_parser(
6372 "clean", help="Delete files and directories created by this script"
6473 )
@@ -84,6 +93,8 @@ def main():
8493 "--logdir",
8594 type=pathlib.Path,
8695 default=None,
96+ dest="_log_path",
97+ metavar="LOG-DIR",
8798 help="Directory to store log files",
8899 )
89100 for subcommand in (
@@ -113,8 +124,9 @@ def main():
113124 subcommand.add_argument(
114125 "--wasi-sdk",
115126 type=pathlib.Path,
116- dest="wasi_sdk_path ",
127+ dest="_wasi_sdk_path ",
117128 default=None,
129+ metavar="WASI-SDK-PATH",
118130 help="Path to the WASI SDK; defaults to WASI_SDK_PATH environment variable "
119131 "or the appropriate version found in /opt",
120132 )
@@ -132,16 +144,19 @@ def main():
132144 make_host,
133145 build_host,
134146 pythoninfo_host,
147+ package,
135148 ):
136149 subcommand.add_argument(
137150 "--host-triple",
138151 action="store",
139152 default=None,
153+ dest="_host_triple",
154+ metavar="WASI-TRIPLE",
140155 help="The target triple for the WASI host build; "
141- f"defaults to the value found in {os.fsdecode(HERE / 'config.toml')}",
156+ f"defaults to the value found in {os.fsdecode(context.here / 'config.toml')}",
142157 )
143158
144- context = parser.parse_args()
159+ parser.parse_args(namespace=context )
145160
146161 match context.subcommand:
147162 case "configure-build-python":
@@ -166,14 +181,19 @@ def main():
166181 # Configure and build the build Python
167182 _build.configure_build_python(context)
168183 _build.make_build_python(context)
169- _build.pythoninfo_build_python(context)
184+ if not context.quiet:
185+ _build.pythoninfo_build_python(context)
170186
171187 # Configure and build the host/WASI Python
172188 _build.configure_wasi_python(context)
173189 _build.make_wasi_python(context)
174- _build.pythoninfo_wasi_python(context)
190+ if not context.quiet:
191+ _build.pythoninfo_wasi_python(context)
175192 case "clean":
176193 _build.clean_contents(context)
194+ case "package":
195+ _package.gather(context)
196+ _package.archive(context)
177197 case None:
178198 parser.print_help()
179199 case _:
0 commit comments