-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sdformat15: support multiple python versions (#2836)
* add patches * revision bump * update bottle. Signed-off-by: Steve Peters <[email protected]> Co-authored-by: OSRF Build Bot <[email protected]>
- Loading branch information
Showing
1 changed file
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,47 +4,76 @@ class Sdformat15 < Formula | |
url "https://osrf-distributions.s3.amazonaws.com/sdformat/releases/sdformat-15.0.0.tar.bz2" | ||
sha256 "c6c65ac60c502143afc2e4e258d66b92d12c4ab37cf91b5852a50eab4d0f3b1f" | ||
license "Apache-2.0" | ||
revision 1 | ||
|
||
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" | ||
sha256 sonoma: "7316ff9816a4c9b4f3d5ad729b0df09ddf1c484e8788aaa9421830151f07e784" | ||
sha256 ventura: "f9758b06947efe481981dcd0420391c8341a9d3faa58481117f297e504e2ef8f" | ||
end | ||
|
||
depends_on "cmake" => [:build, :test] | ||
depends_on "pkg-config" => [:build, :test] | ||
depends_on "pybind11" => :build | ||
depends_on "[email protected]" => [:build, :test] | ||
depends_on "[email protected]" => [:build, :test] | ||
|
||
depends_on "doxygen" | ||
depends_on "gz-cmake4" | ||
depends_on "gz-math8" | ||
depends_on "gz-tools2" | ||
depends_on "gz-utils3" | ||
depends_on macos: :mojave # c++17 | ||
depends_on "[email protected]" | ||
depends_on "tinyxml2" | ||
depends_on "urdfdom" | ||
|
||
def python_cmake_arg | ||
"-DPython3_EXECUTABLE=#{which("python3")}" | ||
patch do | ||
# Support building python bindings against external sdformat library part 1 | ||
# Remove this patch with the next release | ||
url "https://github.com/gazebosim/sdformat/commit/22684cbe9144f9cf15e2df7dfa55457266caca44.patch?full_index=1" | ||
sha256 "3ce3f059b4e549e105ef555479979cb849b75d0ff58d1cb479b3a5cde519ff3f" | ||
end | ||
|
||
patch do | ||
# Support building python bindings against external sdformat library part 2 | ||
# Remove this patch with the next release | ||
url "https://github.com/gazebosim/sdformat/commit/3dcdd55ee7a3ab0ac77b5cce56ba9629b79a70ac.patch?full_index=1" | ||
sha256 "0e7dacc3c576d1188985c3508ed217c50b910f5f9290826703b6411958d28657" | ||
end | ||
|
||
def pythons | ||
deps.map(&:to_formula) | ||
.select { |f| f.name.match?(/^python@3\.\d+$/) } | ||
end | ||
|
||
def python_cmake_arg(python = Formula["[email protected]"]) | ||
"-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 +119,8 @@ def install | |
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}" | ||
system cmd_not_grep_xcode | ||
# check python import | ||
system Formula["[email protected]"].opt_libexec/"bin/python", "-c", "import sdformat15" | ||
pythons.each do |python| | ||
system python.opt_libexec/"bin/python", "-c", "import sdformat15" | ||
end | ||
end | ||
end |