Closed meijieru closed 2 years ago
What kind of dependencies are we talking about? Could you elaborate?
For example, I have the package CloudFlare
installed by the package manager. However, the debugpy
could not find it as debugpy
is installed in virtualenv. So when I start debugging, it complains about the missing packages.
Solved by overriding the pythonPath
function
Hey @meijieru! do you mind sharing what you changed it to? Perhaps we could make a FAQ
out of this.
The default pythonPath
fall back to the virtualenv where debugpy
is installed.
Here I just override it to ignore that path.
function()
local dap_install = require "dap-install"
local dbg_list = require("dap-install.api.debuggers").get_installed_debuggers()
local overrides = {
python = {
adapters = {
type = "executable",
command = "python3",
args = { "-m", "debugpy.adapter" },
},
configurations = {
{
type = "python",
request = "launch",
name = "Launch file",
program = "${file}",
pythonPath = function()
local venv_path = os.getenv "VIRTUAL_ENV"
if venv_path then
local util_sys = require "dap-install.utils.sys"
if util_sys.is_windows() then
return venv_path .. "\\Scripts\\python.exe"
end
return venv_path .. "/bin/python"
end
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
return cwd .. "/venv/bin/python"
elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
return cwd .. "/.venv/bin/python"
else
return "/usr/bin/python3"
end
end,
},
},
},
}
for _, debugger in ipairs(dbg_list) do
dap_install.config(debugger, overrides[debugger])
end
end
Currently, I have to manually instead of the dependences for the python within the environment. Any tips on how to make it works with system packages?