Skip to content

Commit

Permalink
language/python: raise if we can't detect the Python to use for venv
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Jul 9, 2020
1 parent f01d264 commit 1c73393
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ def message
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
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/language/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def virtualenv_install_with_resources(options = {})
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
Expand Down

0 comments on commit 1c73393

Please sign in to comment.