Skip to content

Instantly share code, notes, and snippets.

@mattmc3
Created April 6, 2017 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmc3/32600624f77d90cb7e68d5ab93f02260 to your computer and use it in GitHub Desktop.
Save mattmc3/32600624f77d90cb7e68d5ab93f02260 to your computer and use it in GitHub Desktop.
VSCode tasks for Python 3
// # Be sure to set up virtualenv
// python3 -m venv .env
// source .env/bin/activate
// pip install --upgrade pip
// pip freeze > requirements.txt
//
// ${workspaceRoot} the path of the folder opened in VS Code
// ${file} the current opened file
// ${fileBasename} the current opened file's basename
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
{
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"showOutput": "always",
"options": {
"cwd": "${workspaceRoot}"
},
"args": [
"-c"
],
"tasks": [
{
"taskName": "Python Run",
"suppressTaskName": true,
"isBuildCommand": true,
"args": ["source ${workspaceRoot}/.env/bin/activate; echo \"running ${file}\"; python ${file}; deactivate"]
},
{
"taskName": "pytest",
"suppressTaskName": true,
"isTestCommand": true,
"args": ["source ${workspaceRoot}/.env/bin/activate; py.test; deactivate"]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment