Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
ledger: find Homebrew Python when building --HEAD.
Browse files Browse the repository at this point in the history
When building --HEAD and --with-python, CMake gets confused by multiple
python installations, e.g. when both Homebrew and system Pythons exist
(see #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 <[email protected]>
  • Loading branch information
gadomski authored and MikeMcQuaid committed Mar 5, 2014
1 parent 735cd28 commit 0c5da90
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Library/Formula/ledger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c5da90

Please sign in to comment.