[英]VS Code - Run Debug Configuration for a console_script in module mode
My setup.py
has the following console_scripts as entry points:我的setup.py
有以下 console_scripts 作为入口点:
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.如何在这些模块属性中输入 VS 代码调试配置。 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如果我使用if __name__ == "__main__": do_something()
但想要单独的 launch.json 文件,我有这个可以运行模块,具体取决于 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
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.至少您需要每个入口点有一个单独的模块,或者有一个带有命令行参数的模块,然后选择要调用的 function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.