Merge pull request #7959 from Bo98/python3.7

language/python: allow python@3.7 to be used for virtualenvs
This commit is contained in:
Bo Anderson 2020-07-09 16:44:54 +01:00 committed by GitHub
commit 04370d4663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -180,8 +180,9 @@ module Language
def virtualenv_install_with_resources(options = {})
python = options[:using]
if python.nil?
pythons = %w[python python3 python@3 python@3.8 pypy pypy3]
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