homebrew-core/Formula/bup.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

61 lines
1.4 KiB
Ruby

require 'formula'
class Bup < Formula
homepage 'https://github.com/bup/bup'
url 'https://github.com/bup/bup/archive/bup-0.25-rc1.tar.gz'
sha1 'b88bd38d6f00a646faf0bd1f561595ebc0e55b30'
head 'https://github.com/bup/bup.git', :branch => 'master'
option "run-tests", "Run unit tests after compilation"
depends_on :python
# patch to make the `--prefix` parameter work
# found at https://github.com/apenwarr/bup/pull/5
def patches
DATA
end
def install
python do
ohai ENV['PATH']
system "./configure", "--prefix=#{prefix}"
system "make"
end
system "make test" if build.include? "run-tests"
system "make install"
end
end
__END__
diff --git a/Makefile b/Makefile
index ce91ff0..ecb0604 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+-include config/config.vars
OS:=$(shell uname | sed 's/[-_].*//')
CFLAGS:=-Wall -O2 -Werror $(PYINCLUDE)
SOEXT:=.so
@@ -14,9 +15,6 @@ bup: lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
Documentation/all: bup
-INSTALL=install
-PYTHON=python
-PREFIX=/usr
MANDIR=$(DESTDIR)$(PREFIX)/share/man
DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
BINDIR=$(DESTDIR)$(PREFIX)/bin
diff --git a/config/config.vars.in b/config/config.vars.in
index 7bc32ee..a45827c 100644
--- a/config/config.vars.in
+++ b/config/config.vars.in
@@ -1,2 +1,5 @@
CONFIGURE_FILES=@CONFIGURE_FILES@
GENERATED_FILES=@GENERATED_FILES@
+PREFIX=@prefix@
+INSTALL=@INSTALL@
+PYTHON=@PYTHON@