formula: add std_pip_args
This commit is contained in:
parent
ac93842f8d
commit
9597f455aa
@ -1622,6 +1622,19 @@ class Formula
|
|||||||
["--prefix=#{prefix}", "--libdir=#{lib}", "--buildtype=release", "--wrap-mode=nofallback"]
|
["--prefix=#{prefix}", "--libdir=#{lib}", "--buildtype=release", "--wrap-mode=nofallback"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Standard parameters for pip builds.
|
||||||
|
sig {
|
||||||
|
params(prefix: T.any(String, Pathname, FalseClass),
|
||||||
|
build_isolation: T::Boolean).returns(T::Array[String])
|
||||||
|
}
|
||||||
|
def std_pip_args(prefix: self.prefix, build_isolation: false)
|
||||||
|
args = ["--verbose", "--no-deps", "--no-binary=:all:", "--ignore-installed",
|
||||||
|
"--use-feature=no-binary-enable-wheel-cache"]
|
||||||
|
args << "--prefix=#{prefix}" if prefix.present?
|
||||||
|
args << "--no-build-isolation" unless build_isolation
|
||||||
|
args
|
||||||
|
end
|
||||||
|
|
||||||
# Shared library names according to platform conventions.
|
# Shared library names according to platform conventions.
|
||||||
#
|
#
|
||||||
# Optionally specify a `version` to restrict the shared library to a specific
|
# Optionally specify a `version` to restrict the shared library to a specific
|
||||||
|
|||||||
@ -301,12 +301,7 @@ module Language
|
|||||||
|
|
||||||
def do_install(targets, build_isolation: true)
|
def do_install(targets, build_isolation: true)
|
||||||
targets = Array(targets)
|
targets = Array(targets)
|
||||||
args = [
|
args = @formula.std_pip_args(prefix: false, build_isolation: build_isolation)
|
||||||
"-v", "--no-deps", "--no-binary", ":all:",
|
|
||||||
"--use-feature=no-binary-enable-wheel-cache",
|
|
||||||
"--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
|
end
|
||||||
|
|||||||
@ -22,17 +22,19 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
|
|
||||||
describe "#pip_install" do
|
describe "#pip_install" do
|
||||||
it "accepts a string" do
|
it "accepts a string" do
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: true).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", "foo")
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "foo")
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
virtualenv.pip_install "foo"
|
virtualenv.pip_install "foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "accepts a multi-line strings" do
|
it "accepts a multi-line strings" do
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: true).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", "foo", "bar")
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "foo", "bar")
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
|
|
||||||
virtualenv.pip_install <<~EOS
|
virtualenv.pip_install <<~EOS
|
||||||
@ -42,14 +44,16 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "accepts an array" do
|
it "accepts an array" do
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: true).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", "foo")
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "foo")
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
|
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: true).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", "bar")
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "bar")
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
|
|
||||||
virtualenv.pip_install ["foo", "bar"]
|
virtualenv.pip_install ["foo", "bar"]
|
||||||
@ -59,18 +63,20 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
|||||||
res = Resource.new("test")
|
res = Resource.new("test")
|
||||||
|
|
||||||
expect(res).to receive(:stage).and_yield
|
expect(res).to receive(:stage).and_yield
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: true).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", Pathname.pwd)
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", Pathname.pwd)
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
|
|
||||||
virtualenv.pip_install res
|
virtualenv.pip_install res
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works without build isolation" do
|
it "works without build isolation" do
|
||||||
|
expect(formula).to receive(:std_pip_args).with(prefix: false,
|
||||||
|
build_isolation: false).and_return(["--std-pip-args"])
|
||||||
expect(formula).to receive(:system)
|
expect(formula).to receive(:system)
|
||||||
.with(dir/"bin/pip", "install", "-v", "--no-deps", "--no-binary", ":all:",
|
.with(dir/"bin/pip", "install", "--std-pip-args", "foo")
|
||||||
"--use-feature=no-binary-enable-wheel-cache", "--ignore-installed", "--no-build-isolation", "foo")
|
|
||||||
.and_return(true)
|
.and_return(true)
|
||||||
virtualenv.pip_install("foo", build_isolation: false)
|
virtualenv.pip_install("foo", build_isolation: false)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user