-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathessentia.rb
91 lines (73 loc) · 2.75 KB
/
essentia.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class Essentia < Formula
desc "Library for audio analysis and audio-based music information retrieval"
homepage "http://essentia.upf.edu"
head 'https://github.com/MTG/essentia.git'
include Language::Python::Virtualenv
depends_on "pkg-config" => :build
depends_on "gcc" => :build
depends_on "eigen"
depends_on "libyaml"
depends_on "fftw"
depends_on "ffmpeg@2.8"
depends_on "libsamplerate"
depends_on "libtag"
depends_on "chromaprint"
depends_on "gaia" => :optional
depends_on "tensorflow" => :optional
option "without-python", "Build without Python 3.9 support"
depends_on "python@3.9" if build.with? "python"
depends_on "numpy" if build.with? "python"
resource "six" do
url "https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz"
sha256 "236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"
end
def install
build_flags = [
"--mode=release",
"--with-examples",
"--with-vamp",
"--prefix=#{prefix}"
]
if build.with? "gaia"
build_flags += ["--with-gaia"]
end
if build.with? "tensorflow"
build_flags += ["--with-tensorflow"]
end
system Formula["python@3.9"].opt_bin/"python3", "waf", "configure", *build_flags
system Formula["python@3.9"].opt_bin/"python3", "waf"
system Formula["python@3.9"].opt_bin/"python3", "waf", "install"
python_flags = [
"--mode=release",
"--only-python",
"--prefix=#{prefix}"
]
# Adding path to newly installed Essentia
ENV['PKG_CONFIG_PATH'] = "#{prefix}/lib/pkgconfig:" + ENV['PKG_CONFIG_PATH']
if build.with? "python"
system Formula["python@3.9"].opt_bin/"python3", "waf", "configure", *python_flags
system Formula["python@3.9"].opt_bin/"python3", "waf"
system Formula["python@3.9"].opt_bin/"python3", "waf", "install"
resource("six").stage do
system Formula["python@3.9"].opt_bin/"python3", *Language::Python.setup_install_args(libexec)
end
version = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
site_packages = "lib/python#{version}/site-packages"
pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
(prefix/site_packages/"homebrew-essentia.pth").write pth_contents
end
end
test do
system "#{bin}/essentia_streaming_extractor_music",
"/System/Library/Sounds/Glass.aiff",
"Glass.json"
py_test = <<~EOS
import essentia.standard as estd
import essentia.streaming as estr
estd.MusicExtractor()("/System/Library/Sounds/Glass.aiff")
EOS
if build.with? "python"
system Formula["python@3.9"].opt_bin/"python3", "-c", "#{py_test}"
end
end
end