Skip to content

Commit

Permalink
gz-msgs11: support multiple python versions (#2842)
Browse files Browse the repository at this point in the history
* Symlink generated python files to versioned python folders.
* revision bump
* update  bottle.

Signed-off-by: Steve Peters <[email protected]>
Co-authored-by: OSRF Build Bot <[email protected]>
  • Loading branch information
scpeters and osrfbuild authored Nov 1, 2024
1 parent 9e0401b commit 7fc0eaa
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions Formula/gz-msgs11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ class GzMsgs11 < Formula
url "https://osrf-distributions.s3.amazonaws.com/gz-msgs/releases/gz-msgs-11.0.1.tar.bz2"
sha256 "4154cea1cf4e8c2b9b40962e44d6ab46b4f767ffab3809e4b6b4022904524fcb"
license "Apache-2.0"
revision 1
revision 2

head "https://github.com/gazebosim/gz-msgs.git", branch: "gz-msgs11"

bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 sonoma: "97c50f8eeb15c758fc6c5676c87ab866b33bd50fda9679f201dbe34ac81286b8"
sha256 ventura: "01f8c71a773518ed8fcd17d0c2bc91c30920753d149ccb7de0af0f2eb00421b6"
end

depends_on "[email protected]" => [:build, :test]
depends_on "[email protected]" => [:build, :test]
depends_on "abseil"
depends_on "cmake"
depends_on "gz-cmake4"
Expand All @@ -17,11 +25,15 @@ class GzMsgs11 < Formula
depends_on macos: :high_sierra # c++17
depends_on "pkg-config"
depends_on "protobuf"
depends_on "[email protected]"
depends_on "tinyxml2"

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 = Formula["[email protected]"])
"-DPython3_EXECUTABLE=#{python.opt_libexec}/bin/python"
end

def install
Expand All @@ -35,8 +47,15 @@ def install
system "make", "install"
end

(lib/"python3.12/site-packages").install Dir[lib/"python/*"]
rmdir prefix/"lib/python"
# this installs python files for each message that can be used by multiple
# versions of python, so symlink the files to versioned python folders
pythons.each do |python|
# remove @ from formula name
python_name = python.name.tr("@", "")
# symlink the python files directly instead of the parent folder to avoid
# brew link errors if there is a pre-existing __pycache__ folder
(lib/"#{python_name}/site-packages/gz/msgs11").install_symlink Dir[lib/"python/gz/msgs11/*"]
end
end

test do
Expand Down Expand Up @@ -73,6 +92,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 gz.msgs11"
pythons.each do |python|
system python.opt_libexec/"bin/python", "-c", "import gz.msgs11"
end
end
end

0 comments on commit 7fc0eaa

Please sign in to comment.