Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Platforms/WASI/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,19 @@ def call(command, *, context=None, quiet=False, **kwargs):
stderr = subprocess.STDOUT
_shared.log("📝", f"Logging output to {stdout.name} (--quiet)...")

subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr)
try:
subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr)
except subprocess.CalledProcessError as error:
if quiet:
_shared.log("❌", f"Exit code {error.returncode}")
separator()
with open(stdout.name, encoding="utf-8") as file:
lines = file.readlines()
# Inefficient, but the log shouldn't be dramatically large.
print("".join(lines[-10:]), end="")
if not lines[-1].endswith("\n"):
print()
sys.exit(error.returncode)


@subdir("build_python_path", clean_ok=True)
Expand Down Expand Up @@ -163,8 +175,7 @@ def make_build_python(context, _working_dir):
cmd = [
binary,
"-c",
"import sys; "
"print(f'{sys.version_info.major}.{sys.version_info.minor}')",
"import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')",
]
version = subprocess.check_output(cmd, encoding="utf-8").strip()

Expand Down
84 changes: 47 additions & 37 deletions Platforms/WASI/_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"pathlib",
"shutil",
"subprocess",
"sys",
"_shared",
]

Expand All @@ -12,6 +13,7 @@
import pathlib
import shutil
import subprocess
import sys

import _shared

Expand Down Expand Up @@ -376,45 +378,53 @@ def archive(context):
int(source_date_epoch), datetime.UTC
).strftime(mtime_format)
else:
mtime = subprocess.run(
try:
mtime = subprocess.run(
[
"git",
"log",
"-1",
"--format=tformat:%cd",
f"--date=format:{mtime_format}",
os.fsdecode(context.checkout),
],
env={"TZ": "UTC0"},
capture_output=True,
text=True,
check=True,
).stdout.strip()
except subprocess.CalledProcessError as error:
print(error.output)
sys.exit(error.returncode)

try:
subprocess.run(
[
"git",
"log",
"-1",
"--format=tformat:%cd",
f"--date=format:{mtime_format}",
os.fsdecode(context.checkout),
"tar",
"-c",
"-f",
os.fsdecode(file_path),
"--sort=name",
"--mtime",
mtime,
"--clamp-mtime",
"--owner=0",
"--group=0",
"--numeric-owner",
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime",
"--mode=go+u,go-w",
# Explicitly using `-T` because if you don't compress with threads you can't
# uncompress with them and the size difference is negligible when using
# single-threaded compression.
"--use-compress-program",
"xz -T 0",
to_compress.name,
],
env={"TZ": "UTC0"},
cwd=to_compress.parent,
capture_output=True,
text=True,
check=True,
).stdout.strip()

subprocess.run(
[
"tar",
"-c",
"-f",
os.fsdecode(file_path),
"--sort=name",
"--mtime",
mtime,
"--clamp-mtime",
"--owner=0",
"--group=0",
"--numeric-owner",
"--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime",
"--mode=go+u,go-w",
# Explicitly using `-T` because if you don't compress with threads you can't
# uncompress with them and the size difference is negligible when using
# single-threaded compression.
"--use-compress-program",
"xz -T 0",
to_compress.name,
],
cwd=to_compress.parent,
capture_output=True,
text=True,
check=True,
)
)
except subprocess.CalledProcessError as error:
print(error.output)
sys.exit(error.returncode)
Loading