homebrew-core/Formula/sip.rb

80 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.23/sip-4.19.23.tar.gz"
sha256 "22ca9bcec5388114e40d4aafd7ccd0c4fe072297b628d0c5cdfa2f010c0bc7e7"
head "https://www.riverbankcomputing.com/hg/sip", using: :hg
bottle do
cellar :any_skip_relocation
sha256 "b2dcfcc119e157da7aa3865e90f4f7a083129b2a4e4a30523570aa54ca3db47f" => :catalina
sha256 "6a092e82f96e2898713e83aca3ee9d9782fc2a9baa1d6a4ac665cb784fdef5a1" => :mojave
sha256 "85cfd373309794850293defa3921a23d010b2ef011bb4a93851fd45349bf2a27" => :high_sierra
end
depends_on "python@3.8"
def install
ENV.prepend_path "PATH", Formula["python@3.8"].opt_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