protobuf: build with Python 3

This commit is contained in:
FX Coudert 2018-12-27 12:26:16 +01:00
parent 6ed7b6d3e2
commit f2d2141a67

View file

@ -4,6 +4,7 @@ class Protobuf < Formula
url "https://github.com/protocolbuffers/protobuf.git",
:tag => "v3.6.1.3",
:revision => "66dc42d891a4fc8e9190c524fd67961688a37bbe"
revision 1
head "https://github.com/protocolbuffers/protobuf.git"
bottle do
@ -13,16 +14,11 @@ class Protobuf < Formula
sha256 "52eedfd81a251dbbc72d2ddbe78e1a54c651792bed0601b57c5ef31a53a6b62d" => :sierra
end
option "without-python@2", "Build without python2 support"
deprecated_option "without-python" => "with-python@2"
deprecated_option "with-python3" => "with-python"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "python@2" => :recommended
depends_on "python" => :optional
depends_on "python"
depends_on "python@2"
resource "six" do
url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
@ -48,17 +44,19 @@ class Protobuf < Formula
# Install editor support and examples
doc.install "editors", "examples"
Language::Python.each_python(build) do |python, version|
ENV.append_to_cflags "-I#{include}"
ENV.append_to_cflags "-L#{lib}"
["python2", "python3"].each do |python|
resource("six").stage do
system python, *Language::Python.setup_install_args(libexec)
end
chdir "python" do
ENV.append_to_cflags "-I#{include}"
ENV.append_to_cflags "-L#{lib}"
args = Language::Python.setup_install_args libexec
args << "--cpp_implementation"
system python, *args
system python, *Language::Python.setup_install_args(libexec),
"--cpp_implementation"
end
version = Language::Python.major_minor_version python
site_packages = "lib/python#{version}/site-packages"
pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
(prefix/site_packages/"homebrew-protobuf.pth").write pth_contents
@ -84,7 +82,7 @@ class Protobuf < Formula
EOS
(testpath/"test.proto").write testdata
system bin/"protoc", "test.proto", "--cpp_out=."
system "python2.7", "-c", "import google.protobuf" if build.with? "python@2"
system "python3", "-c", "import google.protobuf" if build.with? "python"
system "python2.7", "-c", "import google.protobuf"
system "python3", "-c", "import google.protobuf"
end
end