homebrew-core/Formula/ledger.rb
Samuel John f6e80bdea2 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00

58 lines
2.1 KiB
Ruby

require 'formula'
class Ledger < Formula
homepage 'http://ledger-cli.org'
url 'https://github.com/downloads/ledger/ledger/ledger-2.6.3.tar.gz'
sha1 '5b8e7d8199acb116f13720a5a469fff1f14b4041'
head 'https://github.com/ledger/ledger.git', :branch => 'master'
option 'debug', 'Build with debugging symbols enabled'
depends_on 'boost'
depends_on :python => :optional
if build.head?
depends_on 'cmake' => :build
depends_on 'ninja' => :build
depends_on 'mpfr'
depends_on 'gmp'
else
depends_on 'gettext'
depends_on 'pcre'
depends_on 'expat'
depends_on 'libofx' => :optional
end
def install
opoo "Homebrew: Sorry, python bindings for --HEAD seem not to install. Help us fixing this!" if build.with? 'python'
# find Homebrew's libpcre
ENV.append 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
if build.head?
args = [((build.include? 'debug') ? 'debug' : 'opt'), "make", "-N", "-j#{ENV.make_jobs}", "--output=build"]
if build.with? 'python'
args << '--python'
# acprep picks up system python because CMake is used
inreplace 'acprep', "self.configure_args = []",
"self.configure_args = ['-DPYTHON_INCLUDE_DIR=#{python.incdir}', '-DPYTHON_LIBRARY=#{python.libdir}/lib#{python.xy}.dylib']"
end
# Support homebrew not at /usr/local. Also support Xcode-only setups:
inreplace 'acprep', 'search_prefixes = [', "search_prefixes = ['#{HOMEBREW_PREFIX}','#{MacOS.sdk_path}/usr',"
system "./acprep", "--prefix=#{prefix}", *args
system "cmake", "-P", "build/cmake_install.cmake", "-DUSE_PYTHON=ON"
else
args = []
if build.with? 'libofx'
args << "--enable-ofx"
# the libofx.h appears to have moved to a subdirectory
ENV.append 'CXXFLAGS', "-I#{Formula.factory('libofx').opt_prefix}/include/libofx"
end
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}", *args
system 'make'
ENV.deparallelize
system 'make install'
end
end
end