Merge pull request #15121 from singingwolfboy/pip-no-build-isolation
Python: allow --no-build-isolation for pip install
This commit is contained in:
commit
a88397096d
@ -264,14 +264,14 @@ module Language
|
|||||||
# Multiline strings are allowed and treated as though they represent
|
# Multiline strings are allowed and treated as though they represent
|
||||||
# the contents of a `requirements.txt`.
|
# the contents of a `requirements.txt`.
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def pip_install(targets)
|
def pip_install(targets, build_isolation: true)
|
||||||
targets = Array(targets)
|
targets = Array(targets)
|
||||||
targets.each do |t|
|
targets.each do |t|
|
||||||
if t.respond_to? :stage
|
if t.respond_to? :stage
|
||||||
t.stage { do_install Pathname.pwd }
|
t.stage { do_install(Pathname.pwd, build_isolation: build_isolation) }
|
||||||
else
|
else
|
||||||
t = t.lines.map(&:strip) if t.respond_to?(:lines) && t.include?("\n")
|
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
|
end
|
||||||
end
|
end
|
||||||
@ -281,11 +281,11 @@ module Language
|
|||||||
#
|
#
|
||||||
# @param (see #pip_install)
|
# @param (see #pip_install)
|
||||||
# @return (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
|
bin_before = Dir[@venv_root/"bin/*"].to_set
|
||||||
man_before = Dir[@venv_root/"share/man/man*/*"].to_set if link_manpages
|
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_after = Dir[@venv_root/"bin/*"].to_set
|
||||||
bin_to_link = (bin_after - bin_before).to_a
|
bin_to_link = (bin_after - bin_before).to_a
|
||||||
@ -301,12 +301,15 @@ module Language
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def do_install(targets)
|
def do_install(targets, build_isolation: true)
|
||||||
targets = Array(targets)
|
targets = Array(targets)
|
||||||
@formula.system @venv_root/"bin/pip", "install",
|
args = [
|
||||||
"-v", "--no-deps", "--no-binary", ":all:",
|
"-v", "--no-deps", "--no-binary", ":all:",
|
||||||
"--use-feature=no-binary-enable-wheel-cache",
|
"--use-feature=no-binary-enable-wheel-cache",
|
||||||
"--ignore-installed", *targets
|
"--ignore-installed"
|
||||||
|
]
|
||||||
|
args << "--no-build-isolation" unless build_isolation
|
||||||
|
@formula.system @venv_root/"bin/pip", "install", *args, *targets
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,6 +67,14 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
|
|
||||||
virtualenv.pip_install res
|
virtualenv.pip_install res
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#pip_install_and_link" do
|
describe "#pip_install_and_link" do
|
||||||
@ -86,7 +94,7 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
FileUtils.touch src_bin/"kilroy"
|
FileUtils.touch src_bin/"kilroy"
|
||||||
bin_after = Dir.glob(src_bin/"*")
|
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)
|
expect(Dir).to receive(:[]).with(src_bin/"*").twice.and_return(bin_before, bin_after)
|
||||||
|
|
||||||
virtualenv.pip_install_and_link "foo"
|
virtualenv.pip_install_and_link "foo"
|
||||||
@ -115,7 +123,7 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
FileUtils.touch src_man/"man5/kilroy.5"
|
FileUtils.touch src_man/"man5/kilroy.5"
|
||||||
man_after = Dir.glob(src_man/"**/*")
|
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_bin/"*").and_return([])
|
||||||
expect(Dir).to receive(:[]).with(src_man/"man*/*").and_return(man_before)
|
expect(Dir).to receive(:[]).with(src_man/"man*/*").and_return(man_before)
|
||||||
expect(Dir).to receive(:[]).with(src_bin/"*").and_return([])
|
expect(Dir).to receive(:[]).with(src_bin/"*").and_return([])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user