Skip to content

Commit 42af697

Browse files
authored
Merge pull request #4807 from andrewachen/fix/surface-build-warnings
Surface build warnings in CI output
2 parents d919022 + 50c253f commit 42af697

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

packaging/MSWindows/BUILD.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def debug(message: str) -> None:
122122
print(" "+message)
123123

124124

125+
def warn(msg: str) -> None:
126+
print(f"Warning: {msg}")
127+
128+
125129
def csv(values: Iterable) -> str:
126130
return ", ".join(str(x) for x in values)
127131

@@ -287,6 +291,11 @@ def log_command(cmd: str | list[str], log_filename: str, **kwargs) -> None:
287291
if ret != 0:
288292
show_tail(log_filename)
289293
raise RuntimeError(f"{cmd!r} failed and returned {ret}, see {log_filename!r}")
294+
# surface warnings even on success:
295+
with open(log_filename, "r") as f:
296+
for line in f:
297+
if line.startswith(("Warning:", "Error:")):
298+
print(line.rstrip())
290299

291300

292301
def find_delete(path: str, name: str, mindepth=0) -> None:
@@ -305,7 +314,7 @@ def find_delete(path: str, name: str, mindepth=0) -> None:
305314

306315
def rmrf(path: str) -> None:
307316
if not os.path.exists(path):
308-
print(f"Warning: {path!r} does not exist")
317+
warn(f"{path!r} does not exist")
309318
return
310319
rmtree(path)
311320

@@ -606,7 +615,7 @@ def delete_dist_files(*exps: str) -> None:
606615
for exp in exps:
607616
matches = glob(f"{DIST}/{exp}")
608617
if not matches:
609-
print(f"Warning: glob {exp!r} did not match any files!")
618+
warn(f"glob {exp!r} did not match any files!")
610619
continue
611620
for path in matches:
612621
if os.path.isdir(path):
@@ -717,7 +726,7 @@ def fixup_zeroconf() -> None:
717726
# since I have no idea why cx_Freeze struggles with it:
718727
zc = find_spec("zeroconf")
719728
if not zc:
720-
print("Warning: zeroconf not found for Python %s" % sys.version)
729+
warn(f"zeroconf not found for Python {sys.version}")
721730
return
722731
zeroconf_dir = os.path.dirname(zc.origin or "")
723732
debug(f"adding zeroconf from {zeroconf_dir!r} to {lib_zeroconf!r}")
@@ -881,7 +890,7 @@ def bundle_dlls(*expr: str) -> None:
881890
for exp in expr:
882891
matches = glob(f"{exp}.dll")
883892
if not matches:
884-
print(f"Warning: no dll matching {exp!r}")
893+
warn(f"no dll matching {exp!r}")
885894
continue
886895
for match in matches:
887896
name = os.path.basename(match)
@@ -1108,7 +1117,7 @@ def find_prefixed_sbom_rec(filename: str, prefixes: list[str]) -> dict[str, Any]
11081117
version = rec["version"]
11091118
debug(f" * {filename!r}: {package!r}, {version!r}")
11101119
return rec
1111-
print(f"Warning: unknown source for filename {filename!r}, tried {prefixes}")
1120+
warn(f"unknown source for filename {filename!r}, tried {prefixes}")
11121121
return {}
11131122

11141123
def rec_py_lib(path: str) -> None:
@@ -1166,7 +1175,7 @@ def rec_cuda(path: str) -> None:
11661175
debug(f" * {path!r}: {package!r}, {version!r}")
11671176
sbom[path] = rec
11681177
else:
1169-
print(f"Warning: no package data found for {path!r}")
1178+
warn(f"no package data found for {path!r}")
11701179

11711180
# python modules:
11721181
debug("adding python modules")

setup.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,17 @@
4040
from xpra.util.system import is_distribution_variant, get_linux_distribution, is_DEB, is_RPM, is_Arch, is_free_threaded
4141
from xpra.util.io import load_binary_file, get_status_output
4242

43+
44+
def warn(msg: str) -> None:
45+
print(f"Warning: {msg}")
46+
47+
48+
def error(msg: str) -> None:
49+
print(f"Error: {msg}")
50+
51+
4352
if BITS != 64:
44-
print(f"Warning: {BITS}-bit architecture, only 64-bits are officially supported")
53+
warn(f"{BITS}-bit architecture, only 64-bits are officially supported")
4554
for _ in range(5):
4655
sleep(1)
4756
print(".")
@@ -132,7 +141,7 @@ def check_pkgconfig() -> None:
132141
v = get_status_output([PKG_CONFIG, "--version"])
133142
has_pkg_config = v[0] == 0 and v[1]
134143
if not has_pkg_config:
135-
print("WARNING: pkg-config not found!")
144+
warn("pkg-config not found!")
136145

137146

138147
check_pkgconfig()
@@ -992,19 +1001,18 @@ def show_switch_info() -> None:
9921001

9931002
def check_sane_defaults() -> None:
9941003
if x11_ENABLED and WIN32:
995-
print("Warning: enabling x11 on MS Windows is unlikely to work!")
1004+
warn("enabling x11 on MS Windows is unlikely to work!")
9961005
if gtk_x11_ENABLED and not x11_ENABLED:
997-
print("Error: you must enable x11 to support gtk_x11!")
1006+
error("you must enable x11 to support gtk_x11!")
9981007
sys.exit(1)
9991008
if client_ENABLED and not gtk3_ENABLED:
1000-
print("Warning: client is enabled but none of the client toolkits are!?")
1009+
warn("client is enabled but none of the client toolkits are!?")
10011010
if DEFAULT and (not client_ENABLED and not server_ENABLED):
1002-
print("Warning: you probably want to build at least the client or server!")
1011+
warn("you probably want to build at least the client or server!")
10031012
if DEFAULT and not pillow_ENABLED:
1004-
print("Warning: including Python Pillow is VERY STRONGLY recommended")
1013+
warn("including Python Pillow is VERY STRONGLY recommended")
10051014
if DEFAULT and (not enc_x264_ENABLED and not vpx_ENABLED):
1006-
print("Warning: no x264 and no vpx support!")
1007-
print(" you should enable at least one of these two video encodings")
1015+
warn("no x264 and no vpx support! you should enable at least one of these two video encodings")
10081016

10091017
check_sane_defaults()
10101018

@@ -1020,7 +1028,7 @@ def check_cython3() -> None:
10201028
print(f"found Cython version {cython.__version__}")
10211029
version = tuple(int(vpart) for vpart in cython.__version__.split('.')[:2])
10221030
except (ValueError, ImportError):
1023-
print("WARNING: unable to detect Cython version")
1031+
warn("unable to detect Cython version")
10241032
else:
10251033
global cython_shared_ENABLED
10261034
if version < (3, ):
@@ -1586,7 +1594,7 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
15861594
print(f"cannot create target dir {target_dir!r}: {e}")
15871595
template_files = os.listdir(dirname)
15881596
if not template_files:
1589-
print(f"Warning: no files found in {dirname!r}")
1597+
warn(f"no files found in {dirname!r}")
15901598
for f in sorted(template_files):
15911599
if f.endswith("osx.conf.in") and not OSX:
15921600
continue
@@ -1595,7 +1603,7 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
15951603
convert_templates(install_dir, subs, list(subdirs) + [f])
15961604
continue
15971605
if not (f.endswith(".in") or f.endswith(".conf") or f.endswith(".txt") or f.endswith(".keys")):
1598-
print(f"Warning: skipped {f!r}")
1606+
warn(f"skipped {f!r}")
15991607
continue
16001608
with open(filename, "r", encoding="latin1") as f_in:
16011609
template = f_in.read()
@@ -1608,6 +1616,8 @@ def convert_templates(install_dir: str, subs: dict[str, str], subdirs: Sequence[
16081616
try:
16091617
config_data = template % subs
16101618
except ValueError:
1619+
# not using error() — the raise below causes a non-zero exit,
1620+
# which log_command() already surfaces via show_tail()
16111621
print(f"error applying substitutions from {filename!r} to {target_file!r}:")
16121622
print(f"{config_data!r}")
16131623
print(f"{subs!r}")
@@ -1743,7 +1753,7 @@ def clean() -> None:
17431753
if fpath not in CLEAN_FILES:
17441754
CLEAN_FILES.append(fpath)
17451755
continue
1746-
print(f"warning unexpected file in source tree: {fpath} with ext={ext}")
1756+
warn(f"unexpected file in source tree: {fpath} with ext={ext}")
17471757
for x in CLEAN_FILES:
17481758
filename = os.path.join(os.getcwd(), x.replace("/", os.path.sep))
17491759
if os.path.exists(filename):
@@ -1848,7 +1858,7 @@ def add_dir(base: str, defs) -> None:
18481858
if os.path.exists(filename):
18491859
add_data_files(base, [filename])
18501860
else:
1851-
print(f"Warning: missing {filename!r}")
1861+
warn(f"missing {filename!r}")
18521862
else:
18531863
assert isinstance(defs, dict)
18541864
for d, sub in defs.items():
@@ -1875,8 +1885,7 @@ def add_DLLs(*dll_names: str) -> None:
18751885
try:
18761886
do_add_DLLs("lib", *dll_names)
18771887
except Exception as e:
1878-
print(f"Error: failed to add DLLs: {dll_names}")
1879-
print(f" {e}")
1888+
error(f"failed to add DLLs: {dll_names}: {e}")
18801889
sys.exit(1)
18811890

18821891
def do_add_DLLs(prefix="lib", *dll_names: str) -> None:
@@ -1919,9 +1928,8 @@ def do_add_DLLs(prefix="lib", *dll_names: str) -> None:
19191928
dll_files.append(dll_path)
19201929
dll_names.remove(dll_name)
19211930
if dll_names:
1922-
print("some DLLs could not be found:")
1923-
for x in dll_names:
1924-
print(f" - {prefix}{x}*.dll")
1931+
missing = ", ".join(f"{prefix}{x}*.dll" for x in dll_names)
1932+
warn(f"some DLLs could not be found: {missing}")
19251933
add_data_files("", dll_files)
19261934

19271935
# list of DLLs we want to include, without the "lib" prefix, or the version and extension
@@ -2306,8 +2314,7 @@ def add_service_exe(script, icon, base_name) -> None:
23062314
try:
23072315
import OpenGL_accelerate #@UnresolvedImport
23082316
except ImportError as e:
2309-
print("Warning: missing OpenGL_accelerate module")
2310-
print(f" {e}")
2317+
warn(f"missing OpenGL_accelerate module: {e}")
23112318
else:
23122319
glmodules["OpenGL_accelerate"] = OpenGL_accelerate
23132320
for module_name, module in glmodules.items():

0 commit comments

Comments
 (0)