2010-07-01 09:30:46 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Vtk < Formula
|
2010-07-01 09:30:46 +00:00
|
|
|
homepage 'http://www.vtk.org'
|
2012-06-13 12:53:24 +00:00
|
|
|
url 'http://www.vtk.org/files/release/5.10/vtk-5.10.0.tar.gz'
|
|
|
|
sha1 '0c9a17e2f446dc78b0500dc5bbd1c6a2864a0191'
|
2010-07-01 09:30:46 +00:00
|
|
|
|
|
|
|
depends_on 'cmake' => :build
|
2012-08-25 16:36:15 +00:00
|
|
|
depends_on :x11 if build.include? 'x11'
|
|
|
|
depends_on 'qt' => :optional if build.include? 'qt'
|
|
|
|
|
|
|
|
if build.include? 'pyqt' and build.include? 'python'
|
|
|
|
depends_on 'sip'
|
|
|
|
depends_on 'pyqt'
|
|
|
|
end
|
2012-06-13 12:53:24 +00:00
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
option 'examples', 'Compile and install various examples'
|
|
|
|
option 'python', 'Enable python wrapping of VTK classes'
|
|
|
|
option 'pyqt', 'Make python wrapped classes available to SIP/PyQt'
|
|
|
|
option 'qt', 'Enable Qt4 extension via the Homebrew qt formula'
|
|
|
|
option 'qt-extern', 'Enable Qt4 extension via non-Homebrew external Qt4'
|
|
|
|
option 'tcl', 'Enable Tcl wrapping of VTK classes'
|
|
|
|
option 'x11', 'Enable X11 extension rather than OSX native Aqua'
|
2010-07-01 09:30:46 +00:00
|
|
|
|
2012-12-04 14:13:13 +00:00
|
|
|
def patches
|
|
|
|
# Fix bug in Wrapping/Python/setup_install_paths.py: http://vtk.org/Bug/view.php?id=13699
|
|
|
|
DATA
|
|
|
|
end
|
|
|
|
|
2010-07-01 09:30:46 +00:00
|
|
|
def install
|
2012-06-13 12:53:24 +00:00
|
|
|
args = std_cmake_args + %W[
|
|
|
|
-DVTK_REQUIRED_OBJCXX_FLAGS=''
|
|
|
|
-DVTK_USE_CARBON=OFF
|
|
|
|
-DBUILD_TESTING=OFF
|
|
|
|
-DBUILD_SHARED_LIBS=ON
|
|
|
|
-DCMAKE_INSTALL_RPATH:STRING='#{lib}/vtk-5.10'
|
|
|
|
-DCMAKE_INSTALL_NAME_DIR:STRING='#{lib}/vtk-5.10'
|
|
|
|
]
|
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
args << '-DBUILD_EXAMPLES=' + ((build.include? 'examples') ? 'ON' : 'OFF')
|
2010-07-01 09:30:46 +00:00
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'python'
|
2012-12-04 14:13:13 +00:00
|
|
|
args << '-DVTK_WRAP_PYTHON=ON'
|
|
|
|
|
|
|
|
# Cmake picks up the system's python dylib, even if we have a brewed one.
|
2011-04-14 17:45:06 +00:00
|
|
|
python_prefix = `python-config --prefix`.strip
|
2012-12-04 14:13:13 +00:00
|
|
|
args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
|
|
|
|
|
2012-06-13 12:53:24 +00:00
|
|
|
# Install to lib and let installer symlink to global python site-packages.
|
|
|
|
# The path in lib needs to exist first and be listed in PYTHONPATH.
|
|
|
|
pydir = lib/which_python/'site-packages'
|
|
|
|
pydir.mkpath
|
2012-12-04 14:13:13 +00:00
|
|
|
ENV['PYTHONPATH'] = pydir
|
|
|
|
args << "-DVTK_PYTHON_SETUP_ARGS:STRING='--prefix=#{prefix} --install-lib=#{pydir} --single-version-externally-managed --record=installed-files.txt'"
|
|
|
|
|
|
|
|
# For Xcode-only systems, the headers of system's python are inside of Xcode
|
|
|
|
if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
|
2012-06-13 12:53:24 +00:00
|
|
|
end
|
2012-12-04 14:13:13 +00:00
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'pyqt'
|
2012-06-13 12:53:24 +00:00
|
|
|
args << '-DVTK_WRAP_PYTHON_SIP=ON'
|
|
|
|
args << "-DSIP_PYQT_DIR='#{HOMEBREW_PREFIX}/share/sip'"
|
2011-05-28 09:01:44 +00:00
|
|
|
end
|
2010-07-01 09:30:46 +00:00
|
|
|
end
|
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'qt' or build.include? 'qt-extern'
|
2012-06-13 12:53:24 +00:00
|
|
|
args << '-DVTK_USE_GUISUPPORT=ON'
|
|
|
|
args << '-DVTK_USE_QT=ON'
|
|
|
|
args << '-DVTK_USE_QVTK=ON'
|
2010-07-01 09:30:46 +00:00
|
|
|
end
|
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
args << '-DVTK_WRAP_TCL=ON' if build.include? 'tcl'
|
2010-07-01 09:30:46 +00:00
|
|
|
|
2012-12-04 14:13:13 +00:00
|
|
|
# Cocoa for everything except x11
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'x11'
|
2012-06-13 12:53:24 +00:00
|
|
|
args << '-DVTK_USE_COCOA=OFF'
|
|
|
|
args << '-DVTK_USE_X=ON'
|
|
|
|
else
|
|
|
|
args << '-DVTK_USE_COCOA=ON'
|
2011-09-04 23:31:55 +00:00
|
|
|
end
|
|
|
|
|
2012-06-13 12:53:24 +00:00
|
|
|
unless MacOS::CLT.installed?
|
|
|
|
# We are facing an Xcode-only installation, and we have to keep
|
|
|
|
# vtk from using its internal Tk headers (that differ from OSX's).
|
|
|
|
args << "-DTK_INCLUDE_PATH:PATH=#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Headers"
|
|
|
|
args << "-DTK_INTERNAL_PATH:PATH=#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Headers/tk-private"
|
|
|
|
end
|
2010-07-01 09:30:46 +00:00
|
|
|
|
|
|
|
args << ".."
|
2012-02-22 04:48:36 +00:00
|
|
|
|
|
|
|
mkdir 'build' do
|
2012-06-13 12:53:24 +00:00
|
|
|
system 'cmake', *args
|
|
|
|
system 'make'
|
|
|
|
system 'make install'
|
|
|
|
end
|
|
|
|
|
2012-08-25 16:36:15 +00:00
|
|
|
(share+'vtk').install 'Examples' if build.include? 'examples'
|
2012-06-13 12:53:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats
|
|
|
|
s = ''
|
|
|
|
vtk = Tab.for_formula 'vtk'
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'python' or vtk.installed_with? 'python'
|
2012-06-13 12:53:24 +00:00
|
|
|
s += <<-EOS.undent
|
|
|
|
For non-homebrew Python, you need to amend your PYTHONPATH like so:
|
|
|
|
export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
|
|
|
|
|
|
|
|
Even without the --pyqt option, you can display native VTK render windows
|
|
|
|
from python. Alternatively, you can integrate the RenderWindowInteractor
|
|
|
|
in PyQt, PySide, Tk or Wx at runtime. Look at
|
|
|
|
import vtk.qt4; help(vtk.qt4) or import vtk.wx; help(vtk.wx)
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
2012-08-25 16:36:15 +00:00
|
|
|
if build.include? 'examples' or vtk.installed_with? '--examples'
|
2012-06-13 12:53:24 +00:00
|
|
|
s += <<-EOS.undent
|
|
|
|
|
|
|
|
The scripting examples are stored in #{HOMEBREW_PREFIX}/share/vtk
|
|
|
|
|
|
|
|
EOS
|
2010-07-01 09:30:46 +00:00
|
|
|
end
|
2012-06-13 12:53:24 +00:00
|
|
|
return s.empty? ? nil : s
|
|
|
|
end
|
|
|
|
|
|
|
|
def which_python
|
|
|
|
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
2010-07-01 09:30:46 +00:00
|
|
|
end
|
|
|
|
end
|
2012-12-04 14:13:13 +00:00
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/Wrapping/Python/setup_install_paths.py b/Wrapping/Python/setup_install_paths.py
|
|
|
|
index 00f48c8..014b906 100755
|
|
|
|
--- a/Wrapping/Python/setup_install_paths.py
|
|
|
|
+++ b/Wrapping/Python/setup_install_paths.py
|
|
|
|
@@ -35,7 +35,7 @@ def get_install_path(command, *args):
|
|
|
|
option, value = string.split(arg,"=")
|
|
|
|
options[option] = value
|
|
|
|
except ValueError:
|
|
|
|
- options[option] = 1
|
|
|
|
+ options[arg] = 1
|
|
|
|
|
|
|
|
# check for the prefix and exec_prefix
|
|
|
|
try:
|