homebrew-core/Formula/sip.rb
2019-12-29 17:37:22 +01:00

79 lines
2.4 KiB
Ruby

class Sip < Formula
desc "Tool to create Python bindings for C and C++ libraries"
homepage "https://www.riverbankcomputing.com/software/sip/intro"
url "https://www.riverbankcomputing.com/static/Downloads/sip/4.19.20/sip-4.19.20.tar.gz"
sha256 "04cc2f87ac97e8718d8e1ef036e3ec26050ab44c21f9277618d5b67432fcbfd6"
head "https://www.riverbankcomputing.com/hg/sip", :using => :hg
bottle do
cellar :any_skip_relocation
sha256 "eae3d43737dcc1d551e21550a8907e4865885f258549bfe20a329846af38a200" => :catalina
sha256 "d06982c72e687ca3549241083f08bc49b9f3802567a8eee06614c1116e5cc11e" => :mojave
sha256 "68f805ae7c8dfcc9c59ef0c4aaaf15485aef98a532b4c13cda559525acd974dd" => :high_sierra
end
depends_on "python"
def install
ENV.prepend_path "PATH", Formula["python"].opt_libexec/"bin"
ENV.delete("SDKROOT") # Avoid picking up /Application/Xcode.app paths
if build.head?
# Link the Mercurial repository into the download directory so
# build.py can use it to figure out a version number.
ln_s cached_download/".hg", ".hg"
# build.py doesn't run with python3
system "python", "build.py", "prepare"
end
version = Language::Python.major_minor_version "python3"
system "python3", "configure.py",
"--deployment-target=#{MacOS.version}",
"--destdir=#{lib}/python#{version}/site-packages",
"--bindir=#{bin}",
"--incdir=#{include}",
"--sipdir=#{HOMEBREW_PREFIX}/share/sip",
"--sip-module", "PyQt5.sip"
system "make"
system "make", "install"
end
def post_install
(HOMEBREW_PREFIX/"share/sip").mkpath
end
test do
(testpath/"test.h").write <<~EOS
#pragma once
class Test {
public:
Test();
void test();
};
EOS
(testpath/"test.cpp").write <<~EOS
#include "test.h"
#include <iostream>
Test::Test() {}
void Test::test()
{
std::cout << "Hello World!" << std::endl;
}
EOS
(testpath/"test.sip").write <<~EOS
%Module test
class Test {
%TypeHeaderCode
#include "test.h"
%End
public:
Test();
void test();
};
EOS
system ENV.cxx, "-shared", "-Wl,-install_name,#{testpath}/libtest.dylib",
"-o", "libtest.dylib", "test.cpp"
system bin/"sip", "-b", "test.build", "-c", ".", "test.sip"
end
end