12

My setup.py has the following console_scripts as entry points:

entry_points={
        'console_scripts': ['script=myapp.app:do_something',
                            'script2=myapp.app:do_something2'],
    },

with the following structure

.
├── myapp
│   ├── __init__.py
│   ├── app.py
│   ├── mod.py
│   ├── mod2.py
│   └── submodules
│   ├── __init__.py
│   └── mod3.py
├── requirements.txt
└── setup.py

and app looking like

##my_app.app

def do_something():
  #do stuff
def do_something2():
  #do other stuff

How can I get VS code debug configuration to enter at these module attributes. I have this that can run the module if I use if __name__ == "__main__": do_something() but want seperate launch.json files depending on the console_scripts

##launch.json
{
  "configurations": [
    {
      "name": "Python: Module",
      "type": "python",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "module": "myapp.app",
      "args": ["--hello world"]
    }
  ]
}

Thought you might be able to do simlar with:

  "module": "myapp.app:do_something",

but alas:

No module named myapp.app:do_something

2 Answers 2

9

There currently isn't a way to make this work. At minimum you need a separate module per entry point or have a single module that took a command-line argument that then chose which function to call.

Sign up to request clarification or add additional context in comments.

3 Comments

It's always nice to know. Thank you
Is this still the case?
@EricHansen yes, launch.json still has no concept of entry points. If you wanted to open a feature request at github.com/microsoft/vscode-python we could consider adding such support.
1

Here is a launch.json that worked for me to debug mkdocs plugins:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "console": "integratedTerminal",
            "module": "mkdocs",
            "args": ["serve"]
        }
    ]
}

It uses "console": "integratedTerminal",.

mkdocs provides the mkdocs entry point that accepts several arguments such as build and serve. This launch.json allowed me to set a breakpoint in a mkdocs plugin python file and stop at that breakpoing after running the mkdocs build/serve process.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.