forked from ska-sa/homebrew-tap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyrap.rb
56 lines (52 loc) · 2.45 KB
/
pyrap.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
require 'formula'
class Pyrap < Formula
homepage 'http://code.google.com/p/pyrap/'
url 'http://pyrap.googlecode.com/files/pyrap-1.1.0.tar.bz2'
sha1 '8901071b09f747f0a210f180f91869e020c9d081'
head 'http://pyrap.googlecode.com/svn/trunk'
depends_on 'scons' => :build
depends_on 'boost'
depends_on 'casacore'
depends_on :python
depends_on 'numpy' => :python
def patches
p = []
# Patch to support compilation on Mac OS 10.7+ (Lion and up) by ignoring sysroot
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/da9264e50c244b84cd92e180b207e13928f7ff93/patch1.diff'
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/c0981d0c27b3086cb7378cf4442b2754abc8a42d/patch2.diff' if build.head?
# Patch to ignore fortran to c library (aka libgfortran)
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/0bda200fb5c8f743c488077e94195c786ecb2486/patch3.diff'
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/5bdd5e6ab42e9551750128c441a775dffaa3feea/patch4.diff' if build.head?
# Patch to disable explicit linking to system Python framework in order to support brew Python (and other non-system versions)
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/0dbf63fba7b4caed537c84eb26c42afc7db0ec23/patch5.diff' if not build.head?
p << 'https://gist.github.com/ludwigschwardt/5195760/raw/a270c600a5870523192a791c6a4459bbddc293b3/patch6.diff' if build.head?
return p.empty? ? nil : p
end
def install
if build.head?
build_cmd = 'batchbuild-trunk.py'
else
build_cmd = 'batchbuild.py'
end
# Obtain information on Python installation
python_xy = "python" + %x(python -c 'import sys;print(sys.version[:3])').chomp
python_site_packages = lib + "#{python_xy}/site-packages"
system "python", "#{build_cmd}",
"--boost-root=#{HOMEBREW_PREFIX}", "--boost-lib=boost_python-mt",
"--enable-hdf5", "--prefix=#{prefix}",
"--python-prefix=#{python_site_packages}",
"--universal=x86_64"
# Get rid of horrible eggs as they trample on other packages via site.py and easy-install.pth
cd "#{python_site_packages}"
rm_f ['easy-install.pth', 'site.py', 'site.pyc']
mkdir 'pyrap'
touch 'pyrap/__init__.py'
Dir['pyrap.*.egg'].each do |egg|
Dir.foreach("#{egg}/pyrap") do |item|
next if ['.', '..', '__init__.py', '__init__.pyc'].include? item
mv "#{egg}/pyrap/#{item}", 'pyrap/'
end
rm_rf egg
end
end
end