From ab4f1047fb1a7326e64200a9f2f056c698d6edc6 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 9 Aug 2022 22:36:39 +0800 Subject: [PATCH 1/2] language/python: use versioned Python name in `detected_python_shebang` Needed for Homebrew/homebrew-core#107517. --- Library/Homebrew/language/python.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 958dbc2487..c0297a85cb 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -111,7 +111,8 @@ module Language raise ShebangDetectionError.new("Python", "formula has multiple Python dependencies") 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 From 6d07c6eaa05801c78ccf5f5657a2774409532482 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 9 Aug 2022 22:38:05 +0800 Subject: [PATCH 2/2] tests: update language/python/shebang spec --- Library/Homebrew/test/language/python/shebang_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/language/python/shebang_spec.rb b/Library/Homebrew/test/language/python/shebang_spec.rb index b269129cc0..4fa44b83f3 100644 --- a/Library/Homebrew/test/language/python/shebang_spec.rb +++ b/Library/Homebrew/test/language/python/shebang_spec.rb @@ -7,7 +7,7 @@ require "utils/shebang" describe Language::Python::Shebang do let(:file) { Tempfile.new("python-shebang") } let(:python_f) do - formula "python" do + formula "python@3.11" do url "https://brew.sh/python-1.0.tgz" end end @@ -15,7 +15,7 @@ describe Language::Python::Shebang do formula "foo" do url "https://brew.sh/foo-1.0.tgz" - depends_on "python" + depends_on "python@3.11" end end @@ -37,7 +37,7 @@ describe Language::Python::Shebang do Utils::Shebang.rewrite_shebang described_class.detected_python_shebang(f), file expect(File.read(file)).to eq <<~EOS - #!#{HOMEBREW_PREFIX}/opt/python/bin/python3 + #!#{HOMEBREW_PREFIX}/opt/python@3.11/bin/python3.11 a b c