forked from codedreality/homebrew-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatplotlib.rb
75 lines (64 loc) · 2.41 KB
/
matplotlib.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require 'formula'
class TexRequirement < Requirement
fatal false
env :userpaths
def satisfied?
quiet_system('latex', '-version') && quiet_system("dvipng", "-version")
end
def message; <<-EOS.undent
LaTeX not found. This is optional for Matplotlib.
If you want, https://www.tug.org/mactex/ provides an installer.
EOS
end
end
class Matplotlib < Formula
homepage 'http://matplotlib.org'
url 'https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz'
sha1 '8578afc86424392591c0ee03f7613ffa9b6f68ee'
head 'https://github.com/matplotlib/matplotlib.git'
depends_on 'pkg-config' => :build
depends_on :python
depends_on :freetype
depends_on :libpng
depends_on 'numpy'
depends_on TexRequirement => :optional
depends_on 'cairo' => :optional
depends_on 'ghostscript' => :optional
depends_on 'pyside' => :optional
depends_on 'pyqt' => :optional
depends_on 'pygtk' => :optional
depends_on 'pygobject' if build.with? 'pygtk'
# On Xcode-only Macs, the Tk headers are not found by matplotlib
depends_on 'homebrew/dupes/tcl-tk' => :optional
depends_on 'pyparsing' => :python
depends_on LanguageModuleDependency.new(:python, 'python-dateutil', 'dateutil')
def patches
p = []
# Fix for freetpe 2.5.1 (https://github.com/samueljohn/homebrew-python/issues/62)
p << 'https://github.com/matplotlib/matplotlib/pull/2623.diff' unless build.head?
return p
end
def install
# Tell matplotlib, where brew is installed
inreplace "setupext.py",
"'darwin': ['/usr/local/', '/usr', '/usr/X11', '/opt/local'],",
"'darwin': ['#{HOMEBREW_PREFIX}', '/usr', '/usr/X11', '/opt/local'],"
# Apple has the Frameworks (esp. Tk.Framework) in a different place
unless MacOS::CLT.installed?
inreplace "setupext.py",
"'/System/Library/Frameworks/',",
"'#{MacOS.sdk_path}/System/Library/Frameworks',"
end
system "python", "setup.py", "install", "--prefix=#{prefix}", "--record=installed.txt", "--single-version-externally-managed"
end
def caveats
s = <<-EOS.undent
If you want to use the `wxagg` backend, do `brew install wxwidgets`.
This can be done even after the matplotlib install.
EOS
end
test do
ohai "This test takes quite a while. Use --verbose to see progress."
system "python", "-c", "import matplotlib as m; m.test()"
end
end