I'm looking at caffeinating more long-running depot_tools commands on
Mac, which use a variety of `subprocess` APIs; one implementation
strategy I'm considering is to wrap more of them, including
`subprocess.run`, but the most obvious name to wrap `subprocess.run`
into is already taken! I think it makes the most sense to name the
`caffeinate` function(s) after the `subprocess` call it wraps.
The callers to other parts of `subprocess` use more of the features
exposed by those APIs. For consistency, I am plumbing through more of
`subprocess.call`'s identifiable behaviors here, too:
* command-to-invoke parameter is named "args"
* as explicitly checked in cpython's subprocess.py's `_posix_spawn`:
77cb39e0c7/Lib/subprocess.py (L1816)
also allow `str`, `bytes`, and `os.PathLike` for the type of `args`,
converting the non-list-like types into a single-element list
* use kwargs packing and unpacking to forward other parameters into
`subprocess.call`
kwargs packing does not provide perfect emulation as implemented:
77cb39e0c7/Lib/subprocess.py (L386)
`timeout` could be provided as a positional parameter. However, Python
documents all subprocess.call parameters as keyword only:
https://docs.python.org/3.12/library/subprocess.html#older-high-level-api
...specifically because they don't want to bother distinguishing
between parameters "local" to a higher-level `subprocess` helper and
those that get forwarded (via `**kwargs`) to the underlying `Popen`,
so I think it is reasonable to follow their lead on that.
Bug: 462507017
Change-Id: Ia520ced7f8188c23c38826d22ccf20a3c52ddfc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7181621
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Adam Norberg <norberg@google.com>
gclient_paths.GetPrimarySolutionPath() finds primary
solution path from current directory, so it would fail
if it is invoked from outside of workspace.
Pass directory to gclient_paths.GetPrimarySolutionPath
so it could find workspace correctly if it is invoked
ninja outside of workspace.
Bug: 441240584
Change-Id: I873f7883873e143ec8a64ee0e636042ac2336a2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6898614
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Tweak the code in ninja.py so it would only skip directories in $PATH
that are named "depot_tools". The existing detection logic skips
"foo_depot_tools". Also rename functions in the file to follow Python
Style and auto-format the file.
Change-Id: I631958768168f0d673b824c8e14783d2c6f65563
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6259139
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.
Reformatted using:
files=( $(
git ls-tree -r --name-only HEAD | \
grep -Ev -e '^(third_party|recipes)/' | \
grep '\.py$';
git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"
The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py
These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py
Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
The `ninja.py` script fails for this invocation:
```
ninja -C C:\Code\f\engine\src\out\host_debug_unopt\
flutter_windows_unittests.exe
```
However, this works as expected:
```
ninja.exe -C C:\Code\f\engine\src\out\host_debug_unopt\
flutter_windows_unittests.exe
```
Notice how there are extra spaces between the DIR and target. This bug breaks the Flutter engine's build integration with Visual Studio after `ninja.exe` was removed from depot_tools.
Here is an example MSBuild target that runs into this issue:
```xml
<Target Name="Build">
<Exec Command="call ninja -C $(OutDir) flutter_windows_unittests.exe" />
</Target>
```
Change-Id: Ib0022bc48151de438ac209fd07e0183872538ac6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4215121
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Loïc Sharma <loicsharma@google.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
At present when looking for ninja, main only searches in two locations, gclient root and src. The Electron project lists Chromium’s src as a dependency in its DEPS file, so Ninja won’t be in the primary solution’s path (as it’s a transitive dependency, not a direct dependency of Chromium). This change adapts existing logic to account for that case.
Change-Id: I35aea29135d5968722a308bfb6dbb8a727550b42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4203207
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
In Skia (for example), GetPrimarySolutionPath works, but FindGclientRoot
does not (users tend not to use gclient to sync DEPS, etc).
Without this change, we'd get to the loop. If a user had pulled ninja to
third_party/ninja/ninja, then it would work just fine. If they hadn't,
python would throw an exception on the os.path.join line, because we'd
be passing a NoneType as the first argument.
Bug: chromium:1340825
Change-Id: Iab86450c5b6f00bc9c2716b9504debc9a56d9bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4034942
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Nico Weber <thakis@chromium.org>