99 lines
3.7 KiB
Ruby
99 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/90/05/07013eaf1b67fb3d3e6424edab495cde912d80d9ae4ea54c2b70a4bae9ac/sip-6.7.2.tar.gz"
|
|
sha256 "325016c787d0bff20999c420339ad816fbfd39a7c49b2c4dcda12b63c379dbda"
|
|
license any_of: ["GPL-2.0-only", "GPL-3.0-only"]
|
|
head "https://www.riverbankcomputing.com/hg/sip", using: :hg
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_ventura: "1adbaf9bbed7accdf67a733e7b94e8361175e93c633bcb57572aa73d478c79a0"
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "f74454e414778baee52d3aaf39512f8a6895b5cfe9308395ab821908db064943"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "efcb705e94a633217705d51344b14c98d57aaeb4c3e70b1915dbb645af26bc2d"
|
|
sha256 cellar: :any_skip_relocation, monterey: "1d28201501a44c082edcfbddaaafe4216258a36b9a0b5a85fbb8e914b8f8f71e"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "0b21f0b47ffc4da821d079c7c64e900b0dafb762ae63155a40e60d3bfa6e43b4"
|
|
sha256 cellar: :any_skip_relocation, catalina: "a4231ecbd04f5b2f38784b6951c88666f0a25d8803014de70a6918b720218761"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "fc39c8e19d34c024b16bf3aa64bd83cebb3248cef2d6975b544a9842cfd9457d"
|
|
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
|
|
python3 = "python3.10"
|
|
venv = virtualenv_create(libexec, python3)
|
|
resources.each do |r|
|
|
venv.pip_install r
|
|
end
|
|
|
|
system python3, *Language::Python.setup_install_args(prefix, python3)
|
|
|
|
site_packages = Language::Python.site_packages(python3)
|
|
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
|