The "What Would Brett Do?" VS Code extension

Overview

What Would Brett Do?

This EXPERIMENTAL extension is meant to help people set up a Python environment.

The project structure and user experience of this extension is very opinionated. While the supported project structures and workflows are considered common enough, do not be surprised if your particular workflow is not supported, especially if they would be considered advanced to someone new to Python.

This extension is meant act as a playground for the Python extension around environments and solicit feedback on this extension's functionality. If you have any feedback, please start a discussion. Popular functionality may make it's way into the Python extension itself.

Features

Create Environment command

  1. Use an appropriate interpreter (the selected interpreter, ask the user to use the newest version of Python installed, or ask the user to pick an interpreter).
  2. Create a virtual environment in the workspace: python -m venv .venv --prompt ..
  3. Find the most appropriate requirements file (file name contains dev and requirements and ends in .txt, or requirements.txt).
  4. Install the requirements into the environment: python -m pip install --requirement <requirements file>.

Requirements

  1. Python (must be an actively maintained version; typically any version less than 5 years old)
  2. venv (typically only missing on Debian-based Linux distros; install via python3-venv)
  3. pip (typically only missing on Debian-based Linux distros; install via python3-pip)
  4. Python extension (which will be installed automatically)

Extension Settings

N/A

Known Issues

  • The selected Python interpreter must have venv and pip available/installed (something Debian/Ubuntu users must watch out for).
  • Does not support multi-root workspaces (blindly selects the first workspace).
  • Does not try to be smart if no workspace is selected.
Comments
  • `PYTHONUTF8` breaks `ensurepip` under Python 3.7 on Windows

    `PYTHONUTF8` breaks `ensurepip` under Python 3.7 on Windows

    Issue Type: Bug

    Logs:

    workspace: c:\Users\karraj\OneDrive - Microsoft\Desktop\folders\wwbd
    interpreter: C:\Users\karraj\AppData\Local\Microsoft\WindowsApps\python3.7.exe
    Traceback (most recent call last):
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "c:\Users\karraj\.vscode\extensions\brettcannon.wwbd-2022.0.1\python-src\__main__.py", line 9, in <module>
        main()
      File "c:\Users\karraj\.vscode\extensions\brettcannon.wwbd-2022.0.1\python-src\__main__.py", line 5, in main
        runpy.run_module("wwbd", alter_sys=True, run_name="__main__")
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "c:\Users\karraj\.vscode\extensions\brettcannon.wwbd-2022.0.1\python-src\wwbd\__main__.py", line 31, in <module>
        main(sys.argv[1:])
      File "c:\Users\karraj\.vscode\extensions\brettcannon.wwbd-2022.0.1\python-src\wwbd\__main__.py", line 13, in main
        python_path = wwbd_venv.create(args.workspace)
      File "c:\Users\karraj\.vscode\extensions\brettcannon.wwbd-2022.0.1\python-src\wwbd\venv.py", line 24, in create
        venv.create(venv_path, with_pip=True, prompt=prompt)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\venv\__init__.py", line 390, in create
        builder.create(env_dir)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\venv\__init__.py", line 68, in create
        self._setup_pip(context)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\venv\__init__.py", line 288, in _setup_pip
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 411, in check_output
        **kwargs).stdout
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 512, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['c:\\Users\\karraj\\OneDrive - Microsoft\\Desktop\\folders\\wwbd\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.
    

    Extension version: 2022.0.1 VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z) OS version: Windows_NT x64 10.0.22518 Restricted Mode: No

    System Info

    |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2112)| |GPU Status|2d_canvas: enabled
    canvas_oop_rasterization: disabled_off
    direct_rendering_display_compositor: disabled_off_ok
    gpu_compositing: enabled
    multiple_raster_threads: enabled_on
    oop_rasterization: enabled
    opengl: enabled_on
    rasterization: enabled
    raw_draw: disabled_off_ok
    skia_renderer: enabled_on
    video_decode: enabled
    video_encode: enabled
    vulkan: disabled_off
    webgl: enabled
    webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.92GB (2.63GB free)| |Process Argv|--crash-reporter-id ba85916b-757f-4637-bf70-2eefba6645b4| |Screen Reader|no| |VM|0%|

    A/B Experiments
    vsliv368:30146709
    vsreu685:30147344
    python383:30185418
    vspor879:30202332
    vspor708:30202333
    vspor363:30204092
    pythonvspyl392:30443607
    pythontb:30283811
    pythonvspyt551cf:30345471
    pythonptprofiler:30281270
    vshan820:30294714
    vstes263cf:30335440
    vscoreces:30445986
    pythondataviewer:30285071
    vscod805cf:30301675
    pythonvspyt200:30340761
    binariesv615:30325510
    bridge0708:30335490
    bridge0723:30353136
    vsaa593cf:30376535
    vsc1dst:30438360
    pythonvs932:30410667
    wslgetstarted:30449410
    pythonvsnew555:30457759
    vscscmwlcmt:30465135
    cppdebugcf:30475217
    
    

    Pip is actually available as seen below: image

    bug 
    opened by karrtikr 7
  • environment creation command fails, `No module named 'pywin32_bootstrap'`

    environment creation command fails, `No module named 'pywin32_bootstrap'`

    Type: Bug

    Opened a workspace, selected an interpreter and ran WWBD: Create Environment I got an error saying it had failed with the logs below, but it looks like it actually succeeded in creating the environment.

    logs:

    $VIRTUAL_ENV is not set
    workspace: c:\src\test\5
    interpreter: C:\Python310\python.exe
    Error processing line 7 of C:\Users\aamunger\AppData\Roaming\Python\Python310\site-packages\pywin32.pth:
    
      Traceback (most recent call last):
        File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\site.py", line 186, in addpackage
          exec(line)
        File "<string>", line 1, in <module>
      ModuleNotFoundError: No module named 'pywin32_bootstrap'
    
    Remainder of file ignored
    Traceback (most recent call last):
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "c:\Users\aamunger\.vscode-insiders\extensions\brettcannon.wwbd-2022.1.0\python-src\__main__.py", line 9, in <module>
        main()
      File "c:\Users\aamunger\.vscode-insiders\extensions\brettcannon.wwbd-2022.1.0\python-src\__main__.py", line 5, in main
        runpy.run_module("wwbd", alter_sys=True, run_name="__main__")
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\runpy.py", line 224, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "c:\Users\aamunger\.vscode-insiders\extensions\brettcannon.wwbd-2022.1.0\python-src\wwbd\__main__.py", line 31, in <module>
        main(sys.argv[1:])
      File "c:\Users\aamunger\.vscode-insiders\extensions\brettcannon.wwbd-2022.1.0\python-src\wwbd\__main__.py", line 13, in main
        python_path = wwbd_venv.create(args.workspace)
      File "c:\Users\aamunger\.vscode-insiders\extensions\brettcannon.wwbd-2022.1.0\python-src\wwbd\venv.py", line 24, in create
        venv.create(venv_path, with_pip=True, prompt=prompt)
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\venv\__init__.py", line 423, in create
        builder.create(env_dir)
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\venv\__init__.py", line 75, in create
        self._setup_pip(context)
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\venv\__init__.py", line 313, in _setup_pip
        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\subprocess.py", line 420, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
      File "C:\Users\aamunger\AppData\Local\Programs\Python\Python310_5\Lib\subprocess.py", line 524, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['c:\\src\\test\\5\\.venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
    

    Extension version: 2022.1.0 VS Code version: Code - Insiders 1.70.0-insider (e9bda7aa4ff76648cfccc1a7bde465443803da71, 2022-08-02T16:56:25.649Z) OS version: Windows_NT x64 10.0.22000 Modes:

    System Info

    |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz (8 x 1498)| |GPU Status|2d_canvas: enabled
    canvas_oop_rasterization: disabled_off
    direct_rendering_display_compositor: disabled_off_ok
    gpu_compositing: enabled
    multiple_raster_threads: enabled_on
    opengl: enabled_on
    rasterization: enabled
    raw_draw: disabled_off_ok
    skia_renderer: enabled_on
    video_decode: enabled
    video_encode: enabled
    vulkan: disabled_off
    webgl: enabled
    webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.59GB (13.07GB free)| |Process Argv|--crash-reporter-id 1202dc88-403d-4ebc-8393-af3551a8bd5b| |Screen Reader|no| |VM|0%|

    A/B Experiments
    vsliv695:30137379
    vsins829:30139715
    vsliv368cf:30146710
    vsreu685:30147344
    python383cf:30185419
    vspor879:30202332
    vspor708:30202333
    vspor363:30204092
    vstes627:30244334
    vslsvsres303:30308271
    pythonvspyl392:30422396
    pythontb:30258533
    pythonptprofiler:30281269
    vshan820:30294714
    pythondataviewer:30285072
    vscod805cf:30301675
    bridge0708:30335490
    bridge0723:30353136
    vsaa593cf:30376535
    pythonvs932:30404738
    wslgetstarted:30449409
    vscscmwlcmt:30465136
    cppdebug:30492333
    pylanb8912:30522163
    vsclangdf:30492506
    c4g48928:30535728
    
    
    opened by amunger 1
  • Write tests for Python code execution

    Write tests for Python code execution

    Can use https://nodejs.org/dist/latest-v16.x/docs/api/fs.html#fsmkdtempsyncprefix-options to create a temporary directory for the workspace. https://mochajs.org/#hooks should help with the cleanup.

    debt 
    opened by brettcannon 1
  • Misleading notification while creating environment

    Misleading notification while creating environment

    Issue Type: Bug

    This maybe a dup of https://github.com/brettcannon/WWBD/issues/17.

    • Select a non-global interpreter
    • See prompt asking to select a global interpreter, select one.
    • Still see the following notification while environment is being created: image

    Extension version: 2022.0.1 VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z) OS version: Windows_NT x64 10.0.22518 Restricted Mode: No

    System Info

    |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2112)| |GPU Status|2d_canvas: enabled
    canvas_oop_rasterization: disabled_off
    direct_rendering_display_compositor: disabled_off_ok
    gpu_compositing: enabled
    multiple_raster_threads: enabled_on
    oop_rasterization: enabled
    opengl: enabled_on
    rasterization: enabled
    raw_draw: disabled_off_ok
    skia_renderer: enabled_on
    video_decode: enabled
    video_encode: enabled
    vulkan: disabled_off
    webgl: enabled
    webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.92GB (2.80GB free)| |Process Argv|--crash-reporter-id ba85916b-757f-4637-bf70-2eefba6645b4| |Screen Reader|no| |VM|0%|

    A/B Experiments
    vsliv368:30146709
    vsreu685:30147344
    python383:30185418
    vspor879:30202332
    vspor708:30202333
    vspor363:30204092
    pythonvspyl392:30443607
    pythontb:30283811
    pythonvspyt551cf:30345471
    pythonptprofiler:30281270
    vshan820:30294714
    vstes263cf:30335440
    vscoreces:30445986
    pythondataviewer:30285071
    vscod805cf:30301675
    pythonvspyt200:30340761
    binariesv615:30325510
    bridge0708:30335490
    bridge0723:30353136
    vsaa593cf:30376535
    vsc1dst:30438360
    pythonvs932:30410667
    wslgetstarted:30449410
    pythonvsnew555:30457759
    vscscmwlcmt:30465135
    cppdebugcf:30475217
    
    
    opened by karrtikr 1
  • Use `$VIRTUAL_ENV` to set the environment

    Use `$VIRTUAL_ENV` to set the environment

    Discussed in https://github.com/brettcannon/WWBD/discussions/3

    Originally posted by brettcannon April 27, 2022 If VS Code is launched from an activated virtual environment, then use that to set the environment for the workspace.

    enhancement 
    opened by brettcannon 0
  • Create a `.gitignore` file for the virtual environment

    Create a `.gitignore` file for the virtual environment

    Discussed in https://github.com/brettcannon/WWBD/discussions/28

    Originally posted by brettcannon May 19, 2022 Effectively implement https://github.com/python/cpython/issues/83417 . Basically we would write a .gitignore file in the virtual environment's directory that just contained *.

    enhancement 
    opened by brettcannon 0
  • Remove progress reporting

    Remove progress reporting

    The progress updates apply to what already occurred, not what's about to occur. Since most of the work of this extension occurs at the end, the updates end up being rather useless.

    Fixes #17

    bug 
    opened by brettcannon 0
  • Fix progress reporting

    Fix progress reporting

    As of now, the progress.report() calls in extension.ts treat it as what to show at that moment (the future). But it turns out the progress notification treats it as what just occurred (the past). So I either need to change it to state what just happened, or drop the updates since the vast majority of the work will be done in the last step (environment creation and installation), at which point knowing that what's already happened isn't quite so useful.

    bug 
    opened by brettcannon 0
  • Windows paths are not being parsed appropriately in JSON output

    Windows paths are not being parsed appropriately in JSON output

    E.g.

    {"executable": "c:\\src\\test\\3\\.venv\\Scripts\\python.exe", "requirementsFile": null}
    

    is triggering an error of:

    Uncaught SyntaxError: Unexpected token s in JSON at position 19
    
    bug 
    opened by brettcannon 0
Releases(v2022.1.0)
A VS Code extension for web-code.

uweb: web-code extension Makes the navigation in web-code easier, adding a few commands. If your workflow is to open a VS Code instance for each indiv

Vojtech Miksu 2 Jun 8, 2022
VS Code extension that adds a red error squiggle to every word in your code.

Dumbisense Dumbisense is a VS Code extension that adds a red error squiggle to every word in your code, with an interesting error message and dino ima

Maggie Liu 9 Sep 3, 2022
Argon - extension for VS Code and plugin for Roblox allowing easy two-way sync of code and instances

About Argon is a simple two-way sync plugin for Roblox and extension for Visual Studio Code allowing developers not only to sync code but every possib

DARK 16 Dec 29, 2022
Eth-explorers-extension - Chrome extension to open Ethereum addresses & transaction hash from any page on popular explorers + dashboards

eth-explorers-extension(s) This repository contains two folders with two extensions that work for address and transactions respectively. 1. eth-addres

Apoorv Lathey 71 Jan 6, 2023
A CodeMirror (v6) extension for adding relative line numbers to your code editor

Relative Line Numbers for CM6 Installation yarn add codemirror-line-numbers-relative Usage import { EditorView } from "@codemirror/view"; import { Edi

Joe Previte 5 Feb 7, 2022
A VS Code extension for solving problems from WorkAt.tech

VSCode-WorkAt VSCode-WorkAt is an extension that lets you write code for WorkAt.tech in VSCode. Check it out on the Marketplace. Features Choose a lan

Aditya Prakash 3 Aug 29, 2022
Marquee is a VS Code extension designed to naturally integrate with your development flow, so that you will no longer lose track of your thoughts while you're coding

Marquee Stay organized with minimal context switching, all inside your Visual Studio Code. Marquee is a VS Code extension designed to naturally integr

stateful 60 Dec 13, 2022
Visual Studio Code extension for formatting and linting Django/Jinja HTML templates using djLint

Visual Studio Code extension for formatting and linting Django/Jinja HTML templates using djLint

Almaz 25 Dec 15, 2022
VS Code Extension for pnpm, pnpm workspace and more.

pnpm-vscode-helper VS Code Extension for better DX with pnpm. Quick Start Type Ctrl(Command) + Shift + P to open workbench commands input. Type ext in

LinbuduLab 21 Dec 10, 2022
Source code of the papers.labml.ai Chrome extension

papers.labml.ai Chrome extension This is the source code of the papers.labml.ai Chrome extension. Get it from Chrome webstore About ?? View informatio

labml.ai 39 Dec 16, 2022
A WASI implementation that uses VS Code's extension host as the implementing API

Project This repo has been populated by an initial template to help get you started. Please make sure to update the content to build a great experienc

Microsoft 93 Dec 24, 2022
Sort imports by path - VS Code extension

Import sort by absolute path The sorting algorithm will group each item in the array and sort (alphabetically) its children that starts with the path

Richard Bidin 3 Feb 2, 2022
VSCode extension with helpful code snippets for SolidJS.

Solid Snippets VSCode extension with helpful code snippets for SolidJS. GET THE EXTENSION Snippets Trigger Content Languages JSX sinput→ Input two-way

SolidJS Community 11 Dec 8, 2022
🎨 VS Code extension for antd v5 design token. Install it now!👇

antd design token VSCode extension for antd v5 design token. Features Provide the hover hint and editor decorations of antd v5 design token, include c

社长长 12 Dec 30, 2022
RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early Roblox site features before they're officially out without any programming experience.

null 10 Nov 28, 2022
Extracts favicon of the current page and calculates their murmurhash. Firefox extension source code.

Favicon to Murmurhash Extracts favicon of the current page and calculates their murmurhash. Shows links to shodan search based on favicon murmurhashes

null 16 Dec 17, 2022
Create, Customize and Commit your project's ReadMe in VS Code with an integrated extension

VS Code Readme Editor ?? A VS Code extension to create, customize and save your Readme without having to leave your project workspace. Built with Type

Sumit Nalavade 22 Dec 29, 2022
GPU Drops' captcha solving extension without affiliate tracking code injection

Noptcha, without affiliate link injection Noptcha is a reCaptcha and hCaptcha solving extension created by GPU Drops. This fork was made because I hat

Sqaaakoi 201 Dec 26, 2022
A simple vs code extension to listen to Quran recitation.

Quran Radio (vscode-extension) A simple vs code extension to listen to Quran recitation. Dependencies Install vlc as it is required for playing the au

Mostafa Wael 24 Dec 12, 2022