From 38a2703aa790430e98a1be583be135a496d8691a Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Sat, 1 Apr 2023 11:31:29 +0200 Subject: [PATCH 1/4] Python: allow --no-build-isolation for pip install --- Library/Homebrew/language/python.rb | 23 +++++++++++-------- .../test/language/python/virtualenv_spec.rb | 8 +++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 506865790a..a1bb1151e8 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -264,14 +264,14 @@ module Language # Multiline strings are allowed and treated as though they represent # the contents of a `requirements.txt`. # @return [void] - def pip_install(targets) + def pip_install(targets, build_isolation: true) targets = Array(targets) targets.each do |t| if t.respond_to? :stage - t.stage { do_install Pathname.pwd } + t.stage { do_install(Pathname.pwd, build_isolation: build_isolation) } else t = t.lines.map(&:strip) if t.respond_to?(:lines) && t.include?("\n") - do_install t + do_install(t, build_isolation: build_isolation) end end end @@ -281,11 +281,11 @@ module Language # # @param (see #pip_install) # @return (see #pip_install) - def pip_install_and_link(targets, link_manpages: false) + def pip_install_and_link(targets, link_manpages: false, build_isolation: true) bin_before = Dir[@venv_root/"bin/*"].to_set man_before = Dir[@venv_root/"share/man/man*/*"].to_set if link_manpages - pip_install(targets) + pip_install(targets, build_isolation: build_isolation) bin_after = Dir[@venv_root/"bin/*"].to_set bin_to_link = (bin_after - bin_before).to_a @@ -301,12 +301,15 @@ module Language private - def do_install(targets) + def do_install(targets, build_isolation: true) targets = Array(targets) - @formula.system @venv_root/"bin/pip", "install", - "-v", "--no-deps", "--no-binary", ":all:", - "--use-feature=no-binary-enable-wheel-cache", - "--ignore-installed", *targets + args = [ + "-v", "--no-deps", "--no-binary", ":all:", + "--use-feature=no-binary-enable-wheel-cache", + "--ignore-installed" + ] + args << "--no-build-isolation" if not build_isolation + @formula.system @venv_root/"bin/pip", "install", args, *targets end end end diff --git a/Library/Homebrew/test/language/python/virtualenv_spec.rb b/Library/Homebrew/test/language/python/virtualenv_spec.rb index 5babc4a240..539039bf99 100644 --- a/Library/Homebrew/test/language/python/virtualenv_spec.rb +++ b/Library/Homebrew/test/language/python/virtualenv_spec.rb @@ -67,6 +67,14 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do virtualenv.pip_install res end + + it "works without build isolation" do + expect(formula).to receive(:system) + .with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:", + "--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "--no-build-isolation", "foo") + .and_return(true) + virtualenv.pip_install("foo", build_isolation: false) + end end describe "#pip_install_and_link" do From 5f51e1549c3ccd3bb9f6be844a8755cec86b69b9 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Sat, 1 Apr 2023 12:36:58 +0200 Subject: [PATCH 2/4] unless --- Library/Homebrew/language/python.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index a1bb1151e8..e231b047a8 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -308,7 +308,7 @@ module Language "--use-feature=no-binary-enable-wheel-cache", "--ignore-installed" ] - args << "--no-build-isolation" if not build_isolation + args << "--no-build-isolation" unless build_isolation @formula.system @venv_root/"bin/pip", "install", args, *targets end end From a62543f30457b18fdf68e1265d898fb9e2f93f7a Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Sat, 1 Apr 2023 13:36:58 +0200 Subject: [PATCH 3/4] forgot splat --- Library/Homebrew/language/python.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index e231b047a8..b8d890e840 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -309,7 +309,7 @@ module Language "--ignore-installed" ] args << "--no-build-isolation" unless build_isolation - @formula.system @venv_root/"bin/pip", "install", args, *targets + @formula.system @venv_root/"bin/pip", "install", *args, *targets end end end From 64ff38674479b10eb64b9c196d08c1527c501d9c Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Sat, 1 Apr 2023 14:20:26 +0200 Subject: [PATCH 4/4] fix tests --- Library/Homebrew/test/language/python/virtualenv_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/language/python/virtualenv_spec.rb b/Library/Homebrew/test/language/python/virtualenv_spec.rb index 539039bf99..f5e03653db 100644 --- a/Library/Homebrew/test/language/python/virtualenv_spec.rb +++ b/Library/Homebrew/test/language/python/virtualenv_spec.rb @@ -94,7 +94,7 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do FileUtils.touch src_bin/"kilroy" bin_after = Dir.glob(src_bin/"*") - expect(virtualenv).to receive(:pip_install).with("foo") + expect(virtualenv).to receive(:pip_install).with("foo", { build_isolation: true }) expect(Dir).to receive(:[]).with(src_bin/"*").twice.and_return(bin_before, bin_after) virtualenv.pip_install_and_link "foo" @@ -123,7 +123,7 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do FileUtils.touch src_man/"man5/kilroy.5" man_after = Dir.glob(src_man/"**/*") - expect(virtualenv).to receive(:pip_install).with("foo") + expect(virtualenv).to receive(:pip_install).with("foo", { build_isolation: true }) expect(Dir).to receive(:[]).with(src_bin/"*").and_return([]) expect(Dir).to receive(:[]).with(src_man/"man*/*").and_return(man_before) expect(Dir).to receive(:[]).with(src_bin/"*").and_return([])