diff --git a/Library/Formula/ledger.rb b/Library/Formula/ledger.rb index 9ac2145d01b8..cb96ae7b857c 100644 --- a/Library/Formula/ledger.rb +++ b/Library/Formula/ledger.rb @@ -34,7 +34,19 @@ def install # Support homebrew not at /usr/local. Also support Xcode-only setups: inreplace 'acprep', 'search_prefixes = [', "search_prefixes = ['#{HOMEBREW_PREFIX}','#{MacOS.sdk_path}/usr'," args = [((build.include? 'debug') ? 'debug' : 'opt'), "make", "install", "-N", "-j#{ENV.make_jobs}", "--output=build"] - args << '--python' if build.with? 'python' + + if build.with? 'python' + # Per #25118, CMake does a poor job of detecting a brewed Python. + # We need to tell CMake explicitly where our default python lives. + # Inspired by + # https://github.com/Homebrew/homebrew/blob/51d054c/Library/Formula/opencv.rb + args << '--python' << '--' + + python_prefix = `python-config --prefix`.strip + args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'" + args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'" + end + system "./acprep", "--prefix=#{prefix}", *args (share+'ledger').install 'python/demo.py', 'test/input/sample.dat', Dir['contrib'] else