diff --git a/Formula/sdformat15.rb b/Formula/sdformat15.rb index 8e642a2c7..864f1da12 100644 --- a/Formula/sdformat15.rb +++ b/Formula/sdformat15.rb @@ -1,21 +1,17 @@ class Sdformat15 < Formula desc "Simulation Description Format" homepage "http://sdformat.org" - url "https://osrf-distributions.s3.amazonaws.com/sdformat/releases/sdformat-15.0.0.tar.bz2" - sha256 "c6c65ac60c502143afc2e4e258d66b92d12c4ab37cf91b5852a50eab4d0f3b1f" + url "https://github.com/gazebosim/sdformat.git", branch: "scpeters/build_python_bindings_separately" + version "15.0.0~pre1" license "Apache-2.0" head "https://github.com/gazebosim/sdformat.git", branch: "sdf15" - bottle do - root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation" - sha256 sonoma: "30f1dd8393161bebe0bb8f3bd3e5cc90462e09e3d04294ea1ed0b6928df19159" - sha256 ventura: "212c79cc2989ba711db1a1cbef8dc86b3ed804c61b1278443767a3e475f33473" - end - depends_on "cmake" => [:build, :test] depends_on "pkg-config" => [:build, :test] depends_on "pybind11" => :build + depends_on "python@3.12" => [:build, :test] + depends_on "python@3.13" => [:build, :test] depends_on "doxygen" depends_on "gz-cmake4" @@ -23,28 +19,40 @@ class Sdformat15 < Formula depends_on "gz-tools2" depends_on "gz-utils3" depends_on macos: :mojave # c++17 - depends_on "python@3.12" depends_on "tinyxml2" depends_on "urdfdom" - def python_cmake_arg - "-DPython3_EXECUTABLE=#{which("python3")}" + def pythons + deps.map(&:to_formula) + .select { |f| f.name.match?(/^python@3\.\d+$/) } + end + + def python_cmake_arg(python = "python@3.13".to_formula) + "-DPython3_EXECUTABLE=#{python.opt_libexec}/bin/python" end def install cmake_args = std_cmake_args cmake_args << "-DBUILD_TESTING=Off" cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpath}" - cmake_args << python_cmake_arg - # Use a build folder + # first build without python bindings mkdir "build" do - system "cmake", "..", *cmake_args + system "cmake", "..", *cmake_args, "-DSKIP_PYBIND11=ON" system "make", "install" end - (lib/"python3.12/site-packages").install Dir[lib/"python/*"] - rmdir prefix/"lib/python" + # now build only the python bindings + pythons.each do |python| + # remove @ from formula name + python_name = python.name.tr("@", "") + mkdir "build_#{python_name}" do + system "cmake", "../python", *cmake_args, python_cmake_arg(python) + system "make", "install" + (lib/"#{python_name}/site-packages").install Dir[lib/"python/*"] + rmdir prefix/"lib/python" + end + end end test do @@ -90,6 +98,8 @@ def install cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}" system cmd_not_grep_xcode # check python import - system Formula["python@3.12"].opt_bin/"python3.12", "-c", "import sdformat15" + pythons.each do |python| + system python.opt_libexec/"bin/python", "-c", "import sdformat15" + end end end