Merge pull request #13669 from carlocab/rw_python_shebang

language/python: use versioned Python name in `detected_python_shebang`
This commit is contained in:
Carlo Cabrera 2022-08-09 23:21:48 +08:00 committed by GitHub
commit ea981adf22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -111,7 +111,8 @@ module Language
raise ShebangDetectionError.new("Python", "formula has multiple Python dependencies") raise ShebangDetectionError.new("Python", "formula has multiple Python dependencies")
end end
python_shebang_rewrite_info(Formula[python_deps.first].opt_bin/"python3") python_dep = python_deps.first
python_shebang_rewrite_info(Formula[python_dep].opt_bin/python_dep.sub("@", ""))
end end
end end

View File

@ -7,7 +7,7 @@ require "utils/shebang"
describe Language::Python::Shebang do describe Language::Python::Shebang do
let(:file) { Tempfile.new("python-shebang") } let(:file) { Tempfile.new("python-shebang") }
let(:python_f) do let(:python_f) do
formula "python" do formula "python@3.11" do
url "https://brew.sh/python-1.0.tgz" url "https://brew.sh/python-1.0.tgz"
end end
end end
@ -15,7 +15,7 @@ describe Language::Python::Shebang do
formula "foo" do formula "foo" do
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
depends_on "python" depends_on "python@3.11"
end end
end end
@ -37,7 +37,7 @@ describe Language::Python::Shebang do
Utils::Shebang.rewrite_shebang described_class.detected_python_shebang(f), file Utils::Shebang.rewrite_shebang described_class.detected_python_shebang(f), file
expect(File.read(file)).to eq <<~EOS expect(File.read(file)).to eq <<~EOS
#!#{HOMEBREW_PREFIX}/opt/python/bin/python3 #!#{HOMEBREW_PREFIX}/opt/python@3.11/bin/python3.11
a a
b b
c c