Skip to content

Commit bc23489

Browse files
jameslambpre-commit-ci[bot]henryiii
authored
refactor: sort RUNENV debugging log output (#357)
Running with `logging.level = "DEBUG"`, `scikit-build-core` emits a log message listing environment variables for the build, like this: ```text 2023-06-05 00:48:26,822 - scikit_build_core - DEBUG - RUNENV: SYSTEM_PULLREQUEST_SOURCECOMMITID=77b0ed1470cbf63d39ddae10915e96cea2804783 BUILD_QUEUEDBY=Microsoft.VisualStudio.Services.TFS CONDA_SHLVL=1 LC_ALL=en_US.UTF-8 LD_LIBRARY_PATH=/usr/local/lib64:/opt/rh/gcc-toolset-12/root/usr/lib64:/opt/rh/gcc-toolset-12/root/usr/lib:/opt/rh/gcc-toolset-12/root/usr/lib64/dyninst:/opt/rh/ gcc-toolset-12/root/usr/lib/dyninst:/usr/local/lib CONDA_EXE=/opt/miniforge/bin/conda AGENT_HOMEDIRECTORY=/__a SYSTEM_POSTLINESSPEED=10000 AGENT_USEWORKSPACEID=true SYSTEM_STAGEDISPLAYNAME=__default AGENT_VERSION=3.220.2 SYSTEM_JOBATTEMPT=1 SYSTEM_TEAMFOUNDATIONSERVERURI=https://dev.azure.com/lightgbm-ci/ AGENT_TOOLSDIRECTORY=/__t INPUT_ARGUMENTS= SYSTEM_DEFINITIONID=1 AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN=true LANG=en_US.UTF-8 ... ``` I've found that very useful when trying to debug build issues in a project I'm working on (microsoft/LightGBM#5061). This PR proposes a change that I think might make it even more useful...sorting that output alphabetically, like this: ```text 2023-06-05 00:48:26,822 - scikit_build_core - DEBUG - RUNENV: AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN=true AGENT_HOMEDIRECTORY=/__a AGENT_TOOLSDIRECTORY=/__t AGENT_USEWORKSPACEID=true AGENT_VERSION=3.220.2 BUILD_QUEUEDBY=Microsoft.VisualStudio.Services.TFS CONDA_EXE=/opt/miniforge/bin/conda CONDA_SHLVL=1 INPUT_ARGUMENTS= LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LD_LIBRARY_PATH=/usr/local/lib64:/opt/rh/gcc-toolset-12/root/usr/lib64:/opt/rh/gcc-toolset-12/root/usr/lib:/opt/rh/gcc-toolset-12/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-12/root/usr/lib/dyninst:/usr/local/lib SYSTEM_DEFINITIONID=1 SYSTEM_JOBATTEMPT=1 SYSTEM_POSTLINESSPEED=10000 SYSTEM_PULLREQUEST_SOURCECOMMITID=77b0ed1470cbf63d39ddae10915e96cea2804783 SYSTEM_STAGEDISPLAYNAME=__default SYSTEM_TEAMFOUNDATIONSERVERURI=https://dev.azure.com/lightgbm-ci/ ``` In addition to making the output a bit easier to scan visually (in my opinion), that also makes the use of text-diffing tools to compare log output a bit easier. Thanks very much for your time and consideration. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 2809cba commit bc23489

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/scikit_build_core/_shutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def _run(
4444

4545
if self.env:
4646
logger.debug(
47-
"RUNENV:\n {}", "\n ".join(f"{k}={v}" for k, v in self.env.items())
47+
"RUNENV:\n {}",
48+
"\n ".join(f"{k}={v}" for k, v in sorted(self.env.items())),
4849
)
4950
logger.debug("RUN: {}", " ".join(options))
5051

0 commit comments

Comments
 (0)