mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
language/python: create venvs with access to system site packages
A user may wish to use two use two brew-installed Python packages together. For example, one might want to `import numpy` when using `jupyterlab` or `ptpython`. Currently, the only ways to do this I'm aware of is with some hacking of `PYTHONPATH` or the creation of `.pth` files in a formula's prefix. A better solution is to allow the virtualenvs that `brew` creates to have access to system site-packages by default, so that `import numpy` inside `ptpython` or `jupyterlab` just works. Partially resolves Homebrew/homebrew-core#76950.
This commit is contained in:
parent
aa14e48f4e
commit
3d3b9874f9
@ -218,7 +218,7 @@ module Language
|
||||
def create
|
||||
return if (@venv_root/"bin/python").exist?
|
||||
|
||||
@formula.system @python, "-m", "venv", @venv_root
|
||||
@formula.system @python, "-m", "venv", "--system-site-packages", @venv_root
|
||||
|
||||
# Robustify symlinks to survive python patch upgrades
|
||||
@venv_root.find do |f|
|
||||
|
@ -15,7 +15,7 @@ describe Language::Python::Virtualenv::Virtualenv, :needs_python do
|
||||
|
||||
describe "#create" do
|
||||
it "creates a venv" do
|
||||
expect(formula).to receive(:system).with("python", "-m", "venv", dir)
|
||||
expect(formula).to receive(:system).with("python", "-m", "venv", "--system-site-packages", dir)
|
||||
virtualenv.create
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user