mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
language/python: raise if we can't detect the Python to use for venv
This commit is contained in:
parent
f01d264c3c
commit
1c73393b47
@ -320,6 +320,18 @@ class FormulaConflictError < RuntimeError
|
||||
end
|
||||
end
|
||||
|
||||
class FormulaUnknownPythonError < RuntimeError
|
||||
def initialize(formula)
|
||||
super <<~EOS
|
||||
The version of Python to use with the virtualenv in the `#{formula.full_name}` formula
|
||||
cannot be guessed automatically because a recognised Python dependency could not be found.
|
||||
|
||||
If you are using a non-standard Python depedency, please add `:using => "python@x.y"` to
|
||||
`virtualenv_install_with_resources` to resolve the issue manually.
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
class FormulaAmbiguousPythonError < RuntimeError
|
||||
def initialize(formula)
|
||||
super <<~EOS
|
||||
|
@ -182,6 +182,7 @@ module Language
|
||||
if python.nil?
|
||||
pythons = %w[python python3 python@3 python@3.7 python@3.8 pypy pypy3]
|
||||
wanted = pythons.select { |py| needs_python?(py) }
|
||||
raise FormulaUnknownPythonError, self if wanted.empty?
|
||||
raise FormulaAmbiguousPythonError, self if wanted.size > 1
|
||||
|
||||
python = wanted.first
|
||||
|
Loading…
x
Reference in New Issue
Block a user