100 lines
3.7 KiB
Ruby
100 lines
3.7 KiB
Ruby
class Sip < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Tool to create Python bindings for C and C++ libraries"
|
|
homepage "https://www.riverbankcomputing.com/software/sip/intro"
|
|
url "https://files.pythonhosted.org/packages/5b/cb/c27c925ae07bd03a2597fa1db17bfc2a4ac57da61aeb90f8ec98ffbb975b/sip-6.6.2.tar.gz"
|
|
sha256 "0e3efac1c5dfd8e525ae57140927df26993e13f58b89d1577c314f4105bfd90d"
|
|
license any_of: ["GPL-2.0-only", "GPL-3.0-only"]
|
|
revision 1
|
|
head "https://www.riverbankcomputing.com/hg/sip", using: :hg
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "d370544a78c735d7d2dbfcaa99caae8d25c6501c527a7a2643e76ffd790ebcc1"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "0900203a4f34ba4dcdcd50f323d3862ffac301c4fa470ab15da0d9722b23fb4d"
|
|
sha256 cellar: :any_skip_relocation, monterey: "955d999f732223fcca3ab150a838bf6b87ab0f3659b9d83c0a0d16da1e179bba"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "c9e3baa09fbe50dafff4514ea2619dde3e04bb68855b03448990014ff5567225"
|
|
sha256 cellar: :any_skip_relocation, catalina: "ea05cc7b23bf7b8f0d21fbfb5c23f47d74b3d0a8d48707cbf1e5e284f27c0d10"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "3f7957b2bf9e0ad5980aba4971a0d590552adce492a70871fe4fc61892480529"
|
|
end
|
|
|
|
depends_on "python@3.10"
|
|
|
|
resource "packaging" do
|
|
url "https://files.pythonhosted.org/packages/df/9e/d1a7217f69310c1db8fdf8ab396229f55a699ce34a203691794c5d1cad0c/packaging-21.3.tar.gz"
|
|
sha256 "dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"
|
|
end
|
|
|
|
resource "ply" do
|
|
url "https://files.pythonhosted.org/packages/e5/69/882ee5c9d017149285cab114ebeab373308ef0f874fcdac9beb90e0ac4da/ply-3.11.tar.gz"
|
|
sha256 "00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3"
|
|
end
|
|
|
|
resource "pyparsing" do
|
|
url "https://files.pythonhosted.org/packages/71/22/207523d16464c40a0310d2d4d8926daffa00ac1f5b1576170a32db749636/pyparsing-3.0.9.tar.gz"
|
|
sha256 "2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"
|
|
end
|
|
|
|
resource "toml" do
|
|
url "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c/toml-0.10.2.tar.gz"
|
|
sha256 "b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
|
|
end
|
|
|
|
def install
|
|
python = Formula["python@3.10"]
|
|
venv = virtualenv_create(libexec, python.bin/"python3")
|
|
resources.each do |r|
|
|
venv.pip_install r
|
|
end
|
|
|
|
system python.bin/"python3", *Language::Python.setup_install_args(prefix),
|
|
"--install-lib=#{prefix/Language::Python.site_packages("python3")}"
|
|
|
|
site_packages = Language::Python.site_packages(python)
|
|
pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
|
|
(prefix/site_packages/"homebrew-sip.pth").write pth_contents
|
|
end
|
|
|
|
test do
|
|
(testpath/"pyproject.toml").write <<~EOS
|
|
# Specify sip v6 as the build system for the package.
|
|
[build-system]
|
|
requires = ["sip >=6, <7"]
|
|
build-backend = "sipbuild.api"
|
|
|
|
# Specify the PEP 566 metadata for the project.
|
|
[tool.sip.metadata]
|
|
name = "fib"
|
|
EOS
|
|
|
|
(testpath/"fib.sip").write <<~EOS
|
|
// Define the SIP wrapper to the (theoretical) fib library.
|
|
|
|
%Module(name=fib, language="C")
|
|
|
|
int fib_n(int n);
|
|
%MethodCode
|
|
if (a0 <= 0)
|
|
{
|
|
sipRes = 0;
|
|
}
|
|
else
|
|
{
|
|
int a = 0, b = 1, c, i;
|
|
|
|
for (i = 2; i <= a0; i++)
|
|
{
|
|
c = a + b;
|
|
a = b;
|
|
b = c;
|
|
}
|
|
|
|
sipRes = b;
|
|
}
|
|
%End
|
|
EOS
|
|
|
|
system "sip-install", "--target-dir", "."
|
|
end
|
|
end
|