ledger: find Homebrew Python when building --HEAD.

When building --HEAD and --with-python, CMake gets confused by multiple
python installations, e.g. when both Homebrew and system Pythons exist
(see https://github.com/Homebrew/homebrew/issues/10393 for one example).
This patch lifts some hacks from
https://github.com/Homebrew/homebrew/blob/51d054c/Library/Formula/opencv.rb
to point CMake to the Homebrew Python only, if one exists and is
installed.

N.B. brew test ledger seems to be  broken when installed --HEAD for
unrelated reasons.

Closes #27095.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>