Merge pull request #7047 from iMichka/shebang
python: add rewrite function for generic shebangs
This commit is contained in:
commit
6a42a66e03
@ -88,6 +88,17 @@ module Language
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.rewrite_python_shebang(python_path)
|
||||||
|
Pathname(".").find do |f|
|
||||||
|
regex = %r{^#! ?/usr/bin/(env )?python([23](\.\d{1,2})?)$}
|
||||||
|
maximum_regex_length = "#! /usr/bin/env pythonx.yyy$".length
|
||||||
|
next unless f.file?
|
||||||
|
next unless regex.match?(f.read(maximum_regex_length))
|
||||||
|
|
||||||
|
Utils::Inreplace.inreplace f.to_s, regex, "#!#{python_path}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Mixin module for {Formula} adding virtualenv support features.
|
# Mixin module for {Formula} adding virtualenv support features.
|
||||||
module Virtualenv
|
module Virtualenv
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user