2014-07-19 22:37:25 +00:00
|
|
|
class BoostPython < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "C++ library for C++/Python interoperability"
|
2014-07-19 22:37:25 +00:00
|
|
|
homepage "http://www.boost.org"
|
2015-05-03 18:30:18 +00:00
|
|
|
url "https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.bz2"
|
|
|
|
sha256 "fdfc204fc33ec79c99b9a74944c3e54bd78be4f7f15e260c0e2700a36dc7d3e5"
|
2014-07-19 22:37:25 +00:00
|
|
|
head "https://github.com/boostorg/boost.git"
|
|
|
|
|
2015-08-03 02:22:25 +00:00
|
|
|
stable do
|
|
|
|
# don't explicitly link a Python framework
|
|
|
|
# https://github.com/boostorg/build/pull/78
|
|
|
|
patch do
|
|
|
|
url "https://gist.githubusercontent.com/tdsmith/9026da299ac1bfd3f419/raw/b73a919c38af08941487ca37d46e711864104c4d/boost-python.diff"
|
|
|
|
sha256 "9f374761ada11eecd082e7f9d5b80efeb387039d3a290f45b61f0730bce3801a"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-29 06:27:23 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
sha256 "7f627fb1887ecaaea4b6b363d300a21c5274a1607c7dc64f2114d3794b5fec11" => :yosemite
|
|
|
|
sha256 "6239719b00615abb9ce2bd40c680b14182325c2e1844c1bea410c002b42ce1db" => :mavericks
|
|
|
|
sha256 "24acf2ddde1edfabe04239856dec6ce85e8652f3c0d5d8cf357b219c2bf3272a" => :mountain_lion
|
|
|
|
end
|
|
|
|
|
2014-07-19 22:37:25 +00:00
|
|
|
option :universal
|
|
|
|
option :cxx11
|
|
|
|
|
2015-05-10 01:47:44 +00:00
|
|
|
option "without-python", "Build without python 2 support"
|
2014-07-19 22:37:25 +00:00
|
|
|
depends_on :python3 => :optional
|
|
|
|
|
|
|
|
if build.cxx11?
|
|
|
|
depends_on "boost" => "c++11"
|
|
|
|
else
|
|
|
|
depends_on "boost"
|
|
|
|
end
|
|
|
|
|
|
|
|
fails_with :llvm do
|
|
|
|
build 2335
|
|
|
|
cause "Dropped arguments to functions when linking with boost"
|
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
ENV.universal_binary if build.universal?
|
|
|
|
|
|
|
|
# "layout" should be synchronized with boost
|
|
|
|
args = ["--prefix=#{prefix}",
|
|
|
|
"--libdir=#{lib}",
|
|
|
|
"-d2",
|
|
|
|
"-j#{ENV.make_jobs}",
|
|
|
|
"--layout=tagged",
|
|
|
|
"--user-config=user-config.jam",
|
|
|
|
"threading=multi,single",
|
|
|
|
"link=shared,static"]
|
|
|
|
|
|
|
|
args << "address-model=32_64" << "architecture=x86" << "pch=off" if build.universal?
|
|
|
|
|
|
|
|
# Build in C++11 mode if boost was built in C++11 mode.
|
|
|
|
# Trunk starts using "clang++ -x c" to select C compiler which breaks C++11
|
|
|
|
# handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works.
|
|
|
|
if build.cxx11?
|
|
|
|
args << "cxxflags=-std=c++11"
|
|
|
|
if ENV.compiler == :clang
|
|
|
|
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++"
|
|
|
|
end
|
|
|
|
elsif Tab.for_name("boost").cxx11?
|
|
|
|
odie "boost was built in C++11 mode so boost-python must be built with --c++11."
|
|
|
|
end
|
|
|
|
|
|
|
|
# disable python detection in bootstrap.sh; it guesses the wrong include directory
|
|
|
|
# for Python 3 headers, so we configure python manually in user-config.jam below.
|
|
|
|
inreplace "bootstrap.sh", "using python", "#using python"
|
|
|
|
|
|
|
|
Language::Python.each_python(build) do |python, version|
|
|
|
|
py_prefix = `#{python} -c "from __future__ import print_function; import sys; print(sys.prefix)"`.strip
|
|
|
|
py_include = `#{python} -c "from __future__ import print_function; import distutils.sysconfig; print(distutils.sysconfig.get_python_inc(True))"`.strip
|
|
|
|
open("user-config.jam", "w") do |file|
|
|
|
|
# Force boost to compile with the desired compiler
|
|
|
|
file.write "using darwin : : #{ENV.cxx} ;\n"
|
|
|
|
file.write <<-EOS.undent
|
|
|
|
using python : #{version}
|
|
|
|
: #{python}
|
|
|
|
: #{py_include}
|
|
|
|
: #{py_prefix}/lib ;
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
system "./bootstrap.sh", "--prefix=#{prefix}", "--libdir=#{lib}", "--with-libraries=python",
|
|
|
|
"--with-python=#{python}", "--with-python-root=#{py_prefix}"
|
|
|
|
|
|
|
|
system "./b2", "--build-dir=build-#{python}", "--stagedir=stage-#{python}",
|
|
|
|
"python=#{version}", *args
|
|
|
|
end
|
|
|
|
|
|
|
|
lib.install Dir["stage-python3/lib/*py*"] if build.with?("python3")
|
|
|
|
lib.install Dir["stage-python/lib/*py*"] if build.with?("python")
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
(testpath/"hello.cpp").write <<-EOS.undent
|
|
|
|
#include <boost/python.hpp>
|
|
|
|
char const* greet() {
|
|
|
|
return "Hello, world!";
|
|
|
|
}
|
|
|
|
BOOST_PYTHON_MODULE(hello)
|
|
|
|
{
|
|
|
|
boost::python::def("greet", greet);
|
|
|
|
}
|
|
|
|
EOS
|
2015-05-03 18:30:18 +00:00
|
|
|
Language::Python.each_python(build) do |python, _|
|
|
|
|
pyflags = (`#{python}-config --includes`.strip +
|
|
|
|
`#{python}-config --ldflags`.strip).split(" ")
|
|
|
|
system ENV.cxx, "-shared", "hello.cpp", "-lboost_#{python}", "-o", "hello.so", *pyflags
|
2014-07-19 22:37:25 +00:00
|
|
|
output = `#{python} -c "from __future__ import print_function; import hello; print(hello.greet())"`
|
2015-08-03 02:22:25 +00:00
|
|
|
assert_match "Hello, world!", output
|
2014-07-19 22:37:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|