Module: Language::Python::Shebang
- Defined in:
- language/python.rb
Overview
Mixin module for Formula adding shebang rewrite features.
Class Method Summary collapse
Class Method Details
.detected_python_shebang(formula = self, use_python_from_path: false) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'language/python.rb', line 106 def detected_python_shebang(formula = self, use_python_from_path: false) python_path = if use_python_from_path "/usr/bin/env python3" else python_deps = formula.deps.map(&:name).grep(/^python(@.*)?$/) raise ShebangDetectionError.new("Python", "formula does not depend on Python") if python_deps.empty? if python_deps.length > 1 raise ShebangDetectionError.new("Python", "formula has multiple Python dependencies") end python_dep = python_deps.first Formula[python_dep].opt_bin/python_dep.sub("@", "") end python_shebang_rewrite_info(python_path) end |