Skip to content

Update Pyramid debug template to use python -m pyramid.scripts.pserve #2427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JDeuce opened this issue Aug 22, 2018 · 8 comments
Closed

Update Pyramid debug template to use python -m pyramid.scripts.pserve #2427

JDeuce opened this issue Aug 22, 2018 · 8 comments
Assignees
Labels
area-debugging debt Covers everything internal: CI, testing, refactoring of the codebase, etc. good first issue

Comments

@JDeuce
Copy link

JDeuce commented Aug 22, 2018

Hi there has been an issue reported before where the "Pyramid" debug option tries to find the wrong pserve on some platforms.

#530

The fix was submitted here:

f22b451

And it added this block of code to fix it, which uses pserve.exe on Windows and pserve on everything else:
https://github.com/jpfarias/vscode-python/blob/master/src/client/debugger/Main.ts#L217-L224

I don't believe this fix was sufficient as today using VSCode 1.26.1 and vscode-python 2018.7.1 I was getting launch error Unable to locate 'pserve.py' required for debugging Pyramid application

Solution for me was to just not try to use the "program" launch style, but instead use the "module" launch style like the "flask" example. I think you guys should consider changing the default to this as it is simpler to understand ..... and deprecate the custom DebugOption as it is not required nor simpler:

    {
            "name": "Python: Pyramid",
            "type": "python",
            "request": "launch",
            "module": "pyramid.scripts.pserve",
            "args": [
                "${workspaceFolder}/development.ini"
            ],
            "debugOptions": [
                "RedirectOutput",
            ]
        }

@brettcannon brettcannon changed the title Pyramid debug option pserve path still not good enough for everyone Pyramid debug option failing to find pserver Aug 22, 2018
@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug needs verification area-debugging labels Aug 22, 2018
@JDeuce JDeuce changed the title Pyramid debug option failing to find pserver Pyramid debug option failing to find pserve Aug 22, 2018
@brettcannon brettcannon added needs PR feature-request Request for new features or functionality and removed needs verification bug Issue identified by VS Code Team member as probable bug labels Aug 22, 2018
@brettcannon
Copy link
Member

So our current solution works for me, but your idea does seem reasonable, @JDeuce . I have asked on Twitter whether we can rely on this since none of the Pyramid docs seem to suggest this is a supported way to start up pserve.

@JDeuce
Copy link
Author

JDeuce commented Aug 23, 2018

Ok,
I can refer to the git blame on setup.py for pyramid which shows that the pserve command has been pserve.scripts.main for at least 7 years:
https://github.com/Pylons/pyramid/blame/master/setup.py#L105
when it appears to have been added in the initial commit for pserve
Pylons/pyramid@0e0cb76
I guess if it's not documented they could decide to change it.

I investigated a little more on my system. This is the error I was getting.

image

I had the pythonPath set to the same virtualenv "${workspaceFolder/env}" in both in launch.json and expected it to work. I played with it a bit more and ended up getting the error to go away when I set

"python.pythonPath": "${workspaceFolder}/env/Scripts/python.exe"

in my workspace settings. So I think it has to do with the setup.py console script wrapper (pserve.exe) starting a new interpreter that uses the other path or something, which is an interesting distinction from the other module style launch option.

@stevepiercy
Copy link

none of the Pyramid docs seem to suggest this is a supported way to start up pserve.

@brettcannon I'm not sure whether these two Pyramid docs cover what you did not find. If not, please let me know how to improve them. I'd be happy to update them. Thank you!

@mmerickel
Copy link

I can refer to the git blame on setup.py for pyramid which shows that the pserve command has been pserve.scripts.main for at least 7 years

This is true but the if __name__ == '__main__' support which is required for the -m option to work was only added in 1.5 but from then on it is a supported way to invoke the console scripts.

@brettcannon
Copy link
Member

brettcannon commented Aug 23, 2018

@stevepiercy Those pages didn't cover what I was after as there was no direct mention that python3 -m pyramid.scripts.pserve is an acceptable alternative to the pserve command.

@mmerickel thanks for the clarification! Since Pyramid 1.5 was released in April 2014, I think that's long enough for us to be able to rely on it.

I think the suggestion by @JDeuce will be a win long-term for us as it means less TypeScript code to maintain like we have now and there's no special flag to pass into ptvsd like there is for Django and Flask. The trick, though, is deprecating the Pyramid setting so people have time to transition.

@brettcannon brettcannon added debt Covers everything internal: CI, testing, refactoring of the codebase, etc. good first issue needs PR and removed feature-request Request for new features or functionality needs decision labels Aug 23, 2018
@stevepiercy
Copy link

@brettcannon Gotcha. It's here: https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/commandline.html#using-custom-arguments-to-python-when-running-p-scripts

Do you have a suggestion to improve the wording or elevate it to make it more discoverable for what you were searching? I can update, no problem.

@brettcannon
Copy link
Member

Best I can think is to explicitly link to that mention from the pserve command docs and to either do the same other highly visible places/search result pages or potentially choose to make the m approach what the docs point out everywhere.

@stevepiercy
Copy link

@brettcannon I've got an open PR with some improvements. Please let me know if this hits the mark. Thank you!

@brettcannon brettcannon changed the title Pyramid debug option failing to find pserve Update Pyramid debug template to use python -m pyramid.scripts.pserve Dec 19, 2018
@brettcannon brettcannon self-assigned this Apr 23, 2019
@brettcannon brettcannon added this to the 2019 - June Sprint 13 milestone Jul 4, 2019
@DonJayamanne DonJayamanne self-assigned this Jul 9, 2019
@ghost ghost removed the needs PR label Jul 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging debt Covers everything internal: CI, testing, refactoring of the codebase, etc. good first issue
Projects
None yet
Development

No branches or pull requests

5 participants