98 lines
3.6 KiB
Ruby
98 lines
3.6 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/c6/08/34642c4db19e9d41f43640547c5a997cb9b12b512f8c61d0d476e8b9e883/sip-6.6.1.tar.gz"
|
|
sha256 "696c575c72144122701171f2cc767fe6cc87050ea755a04909152a8508ae10c3"
|
|
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_monterey: "05a83ad491c0d85776d57eb4a88f32e62c7c2993f9f2e14d062dee5ca385d7e3"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "524717eec41d3ed756d6d84a9d292f0c6c270404d04d4b9da1953ad1783c95fd"
|
|
sha256 cellar: :any_skip_relocation, monterey: "372c6e6d792377c0877bf54b6f89f2641b9e259223309a16f316380cdbcdb696"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "292c4973d4abf7809847ffcf5f663c7c63ce8dda1b0dac463c32c088a22623b4"
|
|
sha256 cellar: :any_skip_relocation, catalina: "8dfe30410122af28b6d2f1e6a33cabbcabfdf010626f8d7742dba76f16a44cb8"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "ec3052f27f48036a35a34037abf9b79c237c15d6225da0e66a889d34668d63fa"
|
|
end
|
|
|
|
depends_on "python@3.9"
|
|
|
|
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/31/df/789bd0556e65cf931a5b87b603fcf02f79ff04d5379f3063588faaf9c1e4/pyparsing-3.0.8.tar.gz"
|
|
sha256 "7bf433498c016c4314268d95df76c81b842a4cb2b276fa3312cfb1e1d85f6954"
|
|
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.9"]
|
|
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)
|
|
|
|
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
|