Merge pull request #8880 from iMichka/brew-pth

python: do not add main brewed Python site-package to virtualenv
This commit is contained in:
Michka Popoff 2020-10-08 22:23:20 +02:00 committed by GitHub
commit 0c7a7188c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,7 +159,10 @@ module Language
# Find any Python bindings provided by recursive dependencies
formula_deps = formula.recursive_dependencies
pth_contents = formula_deps.map do |d|
next if d.build?
next if d.build? || d.test?
# Do not add the main site-package provided by the brewed
# Python formula, to keep the virtual-env's site-package pristine
next if python_names.include? d.name
dep_site_packages = Formula[d.name].opt_prefix/Language::Python.site_packages(python)
next unless dep_site_packages.exist?
@ -196,8 +199,7 @@ module Language
def virtualenv_install_with_resources(options = {})
python = options[:using]
if python.nil?
pythons = %w[python python3 pypy pypy3] + Formula.names.select { |name| name.start_with? "python@" }
wanted = pythons.select { |py| needs_python?(py) }
wanted = python_names.select { |py| needs_python?(py) }
raise FormulaUnknownPythonError, self if wanted.empty?
raise FormulaAmbiguousPythonError, self if wanted.size > 1
@ -210,6 +212,10 @@ module Language
venv
end
def python_names
%w[python python3 pypy pypy3] + Formula.names.select { |name| name.start_with? "python@" }
end
# Convenience wrapper for creating and installing packages into Python
# virtualenvs.
class Virtualenv