Skip to content

Commit 2be2600

Browse files
fix(pypi): allow access to system site packages by default (#1584)
Co-authored-by: William Boman <[email protected]>
1 parent 0950b15 commit 2be2600

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lua/mason-core/installer/managers/pypi.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ local function create_venv(pkg)
125125

126126
log.fmt_debug("Found python3 installation version=%s, executable=%s", target.version, target.executable)
127127
ctx.stdio_sink.stdout "Creating virtual environment…\n"
128-
return ctx.spawn[target.executable] { "-m", "venv", VENV_DIR }
128+
return ctx.spawn[target.executable] { "-m", "venv", "--system-site-packages", VENV_DIR }
129129
end
130130

131131
---@param ctx InstallContext
@@ -165,6 +165,7 @@ local function pip_install(pkgs, extra_args)
165165
"pip",
166166
"--disable-pip-version-check",
167167
"install",
168+
"--ignore-installed",
168169
"-U",
169170
extra_args or vim.NIL,
170171
pkgs,

tests/mason-core/installer/managers/pypi_spec.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe("pypi manager", function()
3838
assert.spy(ctx.spawn.python3).was_called_with {
3939
"-m",
4040
"venv",
41+
"--system-site-packages",
4142
"venv",
4243
}
4344
end)
@@ -62,6 +63,7 @@ describe("pypi manager", function()
6263
assert.spy(ctx.spawn.python3).was_called_with {
6364
"-m",
6465
"venv",
66+
"--system-site-packages",
6567
"venv",
6668
}
6769
assert.spy(ctx.spawn[venv_py(ctx)]).was_called(1)
@@ -70,6 +72,7 @@ describe("pypi manager", function()
7072
"pip",
7173
"--disable-pip-version-check",
7274
"install",
75+
"--ignore-installed",
7376
"-U",
7477
{ "--proxy", "http://localhost" },
7578
{ "pip" },
@@ -188,6 +191,7 @@ describe("pypi manager", function()
188191
"pip",
189192
"--disable-pip-version-check",
190193
"install",
194+
"--ignore-installed",
191195
"-U",
192196
vim.NIL, -- install_extra_args
193197
{
@@ -227,6 +231,7 @@ describe("pypi manager", function()
227231
"pip",
228232
"--disable-pip-version-check",
229233
"install",
234+
"--ignore-installed",
230235
"-U",
231236
vim.NIL, -- install_extra_args
232237
{
@@ -253,6 +258,7 @@ describe("pypi manager", function()
253258
"pip",
254259
"--disable-pip-version-check",
255260
"install",
261+
"--ignore-installed",
256262
"-U",
257263
{ "--proxy", "http://localhost:9000" },
258264
{

0 commit comments

Comments
 (0)