From b1d9169ae6229722aca2207fca4cebc0284f2e95 Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Mon, 2 Mar 2015 21:44:35 -0800 Subject: [PATCH] language/python: add package_available? helper Add helper to check whether a module is importable. Closes Homebrew/homebrew#37345. Signed-off-by: Tim D. Smith --- Library/Homebrew/language/python.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index c078484589..4089316bb2 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -92,5 +92,9 @@ module Language --record=installed.txt ] end + + def self.package_available? python, module_name + quiet_system python, "-c", "import #{module_name}" + end end end