aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim D. Smith2015-03-02 21:44:35 -0800
committerTim D. Smith2015-03-03 06:31:29 -0800
commit6863c385bc68571ef5afa431d80bb0db4cbf470d (patch)
tree127be416372500f6d569ab1f20696e8ef8018d50
parent0d7259360ce4d3dc577f237b30d0370753e28c13 (diff)
downloadhomebrew-6863c385bc68571ef5afa431d80bb0db4cbf470d.tar.bz2
language/python: add package_available? helper
Add helper to check whether a module is importable. Closes #37345. Signed-off-by: Tim D. Smith <git@tim-smith.us>
-rw-r--r--Library/Homebrew/language/python.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb
index c07848458..4089316bb 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