'How can I create a launch.json to use pipenv scripts?

I have the following folder structure in a monorepo repository

/--.vscode
/--Services
  --/Service1
  --/Service2
  --/Service3

In each service, I am using pipenv with their commands like dev, stg or prod in order to execute the code.

The problem is when I want to debug code, that I only can use pdb.

The idea is to create a .vscode/launch.json, in order to execute that commands and use the vscode debug instead.

But I cannot build that configuration because I cannot set pipenv run dev

How can I set that configuration?

I set another configuration for a non-monorepo repository and works like this

{
// Use IntelliSense para saber los atributos posibles.
// Mantenga el puntero para ver las descripciones de los existentes atributos.
// Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"args": [],
"python.pythonPath": "${workspaceFolder}/venv/bin/python",
"name": "Run Server",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/wsgi.py",
"console": "integratedTerminal",
"justMyCode": true,
"env": {}
}
]


Solution 1:[1]

If you have the path to your Python interpreter, you can replace python with invoke in the "program" value in launch.json.

You can create a Python VS Code debugging configuration (launch.json) as follows :

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Start app",
            "type": "python",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "program": "path/to/virtualenv/invoke",
            "args": ["app.start"],
            "console": "integratedTerminal",
            "stopOnEntry": false,
        },
    ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MingJie-MSFT