Skip to content

Commit

Permalink
Let python lsps and debuggers access installed packages
Browse files Browse the repository at this point in the history
Currently, installing something like debugpy via Mason installs it to a virtual environment that does not have anything else installed. If you are using a second virtual environment, mason handles things to access installed packages in that environment.
However, if you are using the system python, debugpy or lsps don't see any of your installed packages. For debugpy, this means you cannot run your program. This might be the case when you have packages that you almost always want installed, for example pandas.

This change fixes this by transparently letting mason python packages see the system packages, assuming no other dependencies have been installed to the venv and overwritten them. I think this has no downsides for a purpose like mason - Although this is bad practise for regular python software projects, because it disguises required dependencies, in the case of Mason we don't care about required dependencies so long as they do exist.
  • Loading branch information
BlueDrink9 authored and bluedrink9 committed Jan 7, 2024
1 parent e110bc3 commit 1b6f69a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/mason-core/managers/pip3/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function M.install(packages)

-- Find first executable that manages to create venv
local executable = _.find_first(function(executable)
return pcall(ctx.spawn[executable], { "-m", "venv", VENV_DIR })
return pcall(ctx.spawn[executable], { "-m", "venv", "--system-site-packages", VENV_DIR })
end, executables)

Optional.of_nilable(executable)
Expand Down

0 comments on commit 1b6f69a

Please sign in to comment.