Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Add vscode debug configuration
Browse files Browse the repository at this point in the history
The vscode configuration is now included to specify the virtual
environment and enable debugging from within vscode. Instead of running
the Python files from an external terminal, simply open each file,
browse to Debug in vscode (Shift+Cmd+D), and run. Support for Pipenv
within vscode is still under active development.
microsoft/vscode-python#1238
  • Loading branch information
br3ndonland committed Apr 29, 2018
1 parent f19855c commit a83b6d2
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ misc
*.db
*.sublime-project
*.sublime-workspace
*.code-workspace
*.vscode
*.code-workspace
116 changes: 116 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "${workspaceFolder}/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "module.name"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "1",
"VAR2": "2"
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--max-line-length",
"79"
],
"python.venvPath": "~/.local/share/virtualenvs"
}
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ name = "pypi"
sqlalchemy = "*"
flask = "*"
requests = "*"
pylint = "*"

[dev-packages]

Expand Down
72 changes: 71 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Python Flask CRUD web app with SQLite DB, Google Sign-In, and JSON API
## Repository contents

- [.vscode](.vscode)
- [launch.json](.vscode/launch.json): Configuration file for debugging from within vscode.
- [launch.json](.vscode/launch.json): Configuration file for running and debugging Python files from within vscode.
- [settings.json](.vscode/settings.json): vscode settings override for this repository.
- [info/](info)
- [img/](info/img) - Images used in documentation.
Expand Down Expand Up @@ -128,6 +128,8 @@ pipenv install

The virtual environment can then be activated with `pipenv shell`, which spawns a subshell for the virtual environment. Python files can be run from the Pipenv subshell prompt. The subshell can be exited by simply entering `exit`.

The vscode configuration is also included to specify the virtual environment and enable debugging from within vscode. Instead of running the Python files from an external terminal, simply open each file, browse to Debug in vscode (Shift+Cmd+D), and run. At the time this application was written (April 2018), support for Pipenv within vscode was still [under active development](https://github.com/Microsoft/vscode-python/issues/1238).

Proceed to the [run application instructions below](#run-application).

#### Virtual machine
Expand Down

0 comments on commit a83b6d2

Please sign in to comment.