Code Monkey home page Code Monkey logo

Comments (5)

meijieru avatar meijieru commented on September 28, 2024 2

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

from dap-buddy.nvim.

pocco81 avatar pocco81 commented on September 28, 2024

What kind of dependencies are we talking about? Could you elaborate?

from dap-buddy.nvim.

meijieru avatar meijieru commented on September 28, 2024

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.

from dap-buddy.nvim.

meijieru avatar meijieru commented on September 28, 2024

Solved by overriding the pythonPath function

from dap-buddy.nvim.

pocco81 avatar pocco81 commented on September 28, 2024

Hey @meijieru! do you mind sharing what you changed it to? Perhaps we could make a FAQ out of this.

from dap-buddy.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.