blob: d88aa42d4eaef40c57c346c77b068049631008ca [file] [log] [blame]
Ravago Jones23dac942022-07-31 16:18:54 -07001#!/bin/bash
2
3# --- begin runfiles.bash initialization v2 ---
4# Copy-pasted from the Bazel Bash runfiles library v2.
5set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
6source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
7 source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
8 source "$0.runfiles/$f" 2>/dev/null || \
9 source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
10 source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
11 { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
12# --- end runfiles.bash initialization v2 ---
13
Philipp Schraderebb658f2022-09-17 17:31:09 -070014YAPF="$(rlocation pip_deps_yapf/rules_python_wheel_entry_point_yapf)"
15readonly YAPF
Ravago Jones23dac942022-07-31 16:18:54 -070016
17# Run everything from the root of the tree.
18cd "${BUILD_WORKSPACE_DIRECTORY}"
19
20# Find all the Python files in the repo.
21python_files=($(git ls-tree --name-only --full-tree -r @ \
22 | grep -v '^third_party/' \
23 | (grep '\.py$' || :)))
24
25# If we have any Python files, format them.
26if ((${#python_files[@]} > 0)); then
27 exec "${YAPF}" --in-place --parallel --verbose "${python_files[@]}"
28fi