Ask Your Question
1

Debug/Execute a poetry packaged project

asked 2020-05-28 20:03:38 -0500

rmorison gravatar image

updated 2020-05-28 22:19:45 -0500

I'm trying to debug a https://python-poetry.org/ managed project (https://github.com/djrobstep/migra) with a script command like...

[tool.poetry.scripts]
migra = 'migra:do_command'

I wrote my own run.py like

from migra import do_command

do_command()

and that worked, but seemed a little clunky, to have to add my own code to debug with wing. Is there a better way?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-05-29 08:04:39 -0500

Using 'python -m' is increasingly the standard for launching utilities and tools that are part of Python packages. If it's possible to launch poetry with 'python -m poetry' then you don't need to create a run.py but can instead set Main Entry Point under the Debug tab of Project Properties to Use Selected Entry Point and create a Named Entry Point from there which uses the "Named Module" option with module name poetry.

Another approach would be to start debug from code run by poetry and run it from the command line or Wing's OS Commands tool. I think just adding a run.py is cleaner, but this is documented at https://wingware.com/doc/debug/debugg...

edit flag offensive delete link more

Comments

1

If -m supported -m module:function, yeah would be great. Afaik, there's no python command line arg to set the entrypoint to anything other then the beginning of the script file (or __main__.py for packages.)

run.py it is, then.

rmorison gravatar imagermorison ( 2020-05-29 11:23:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-05-28 20:03:38 -0500

Seen: 94 times

Last updated: May 29