Merge pull request #7047 from iMichka/shebang

python: add rewrite function for generic shebangs
This commit is contained in:
Michka Popoff 2020-02-28 23:35:00 +01:00 committed by GitHub
commit 6a42a66e03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)