homebrew-core/Formula/notmuch.rb

119 lines
4.6 KiB
Ruby

class Notmuch < Formula
include Language::Python::Virtualenv
desc "Thread-based email index, search, and tagging"
homepage "https://notmuchmail.org/"
url "https://notmuchmail.org/releases/notmuch-0.37.tar.xz"
sha256 "0e766df28b78bf4eb8235626ab1f52f04f1e366649325a8ce8d3c908602786f6"
license "GPL-3.0-or-later"
revision 1
head "https://git.notmuchmail.org/git/notmuch", using: :git, branch: "master"
livecheck do
url "https://notmuchmail.org/releases/"
regex(/href=.*?notmuch[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "046ffb5869a9eda612272afeb41b0dd22da13cf7cce94e4e3fa8e711c7df157b"
sha256 cellar: :any, arm64_big_sur: "6fb3ab2c851007505e2f36ee5d10347d910d14509a7c5fcca999d4476488e362"
sha256 cellar: :any, monterey: "94edbd6c448b901be5248c4479c359eb2e98c6cd352e169a0c3b261c3085f292"
sha256 cellar: :any, big_sur: "c21015a05fc6e19faf1b62fa0d7a0709310020d7e1577f5238ed24ab8550524d"
sha256 cellar: :any, catalina: "cc418cca02772fe5dd12b03fccfdeda0e0469057bee105aeb92643523f3a7108"
sha256 cellar: :any_skip_relocation, x86_64_linux: "9166a3ea5cefff981cc8c8c1630724c7982f9b3bb399a9a2177906bd251df2b7"
end
depends_on "doxygen" => :build
depends_on "emacs" => :build
depends_on "libgpg-error" => :build
depends_on "pkg-config" => :build
depends_on "sphinx-doc" => :build
depends_on "glib"
depends_on "gmime"
depends_on "python@3.10"
depends_on "talloc"
depends_on "xapian"
uses_from_macos "zlib", since: :sierra
resource "cffi" do
url "https://files.pythonhosted.org/packages/2b/a8/050ab4f0c3d4c1b8aaa805f70e26e84d0e27004907c5b8ecc1d31815f92a/cffi-1.15.1.tar.gz"
sha256 "d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"
end
resource "pycparser" do
url "https://files.pythonhosted.org/packages/5e/0b/95d387f5f4433cb0f53ff7ad859bd2c6051051cebbb564f139a999ab46de/pycparser-2.21.tar.gz"
sha256 "e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"
end
def python3
"python3.10"
end
def install
ENV.cxx11 if OS.linux?
site_packages = Language::Python.site_packages(python3)
with_env(PYTHONPATH: Formula["sphinx-doc"].opt_libexec/site_packages) do
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--emacslispdir=#{elisp}",
"--emacsetcdir=#{elisp}",
"--bashcompletiondir=#{bash_completion}",
"--zshcompletiondir=#{zsh_completion}",
"--without-ruby"
system "make", "V=1", "install"
end
elisp.install Dir["emacs/*.el"]
bash_completion.install "completion/notmuch-completion.bash"
(prefix/"vim/plugin").install "vim/notmuch.vim"
(prefix/"vim/doc").install "vim/notmuch.txt"
(prefix/"vim").install "vim/syntax"
cd "bindings/python" do
system python3, *Language::Python.setup_install_args(prefix, python3)
end
venv = virtualenv_create(libexec, python3)
venv.pip_install resources
venv.pip_install buildpath/"bindings/python-cffi"
# If installed in non-standard prefixes, such as is the default with
# Homebrew on Apple Silicon machines, other formulae can fail to locate
# libnotmuch.dylib due to not checking locations like /opt/homebrew for
# libraries. This is a bug in notmuch rather than Homebrew; globals.py
# uses a vanilla CDLL instead of CDLL wrapped with `find_library`
# which effectively causes the issue.
#
# CDLL("libnotmuch.dylib") = OSError: dlopen(libnotmuch.dylib, 6): image not found
# find_library("libnotmuch") = '/opt/homebrew/lib/libnotmuch.dylib'
# http://notmuch.198994.n3.nabble.com/macOS-globals-py-issue-td4044216.html
inreplace prefix/site_packages/"notmuch/globals.py",
"libnotmuch.{0:s}.dylib",
opt_lib/"libnotmuch.{0:s}.dylib"
end
def caveats
<<~EOS
The python CFFI bindings (notmuch2) are not linked into shared site-packages.
To use them, you may need to update your PYTHONPATH to include the directory
#{opt_libexec/Language::Python.site_packages(python3)}
EOS
end
test do
(testpath/".notmuch-config").write <<~EOS
[database]
path=#{testpath}/Mail
EOS
(testpath/"Mail").mkpath
assert_match "0 total", shell_output("#{bin}/notmuch new")
system python3, "-c", "import notmuch"
with_env(PYTHONPATH: libexec/Language::Python.site_packages(python3)) do
system python3, "-c", "import notmuch2"
end
end
end