vscode-vyper icon indicating copy to clipboard operation
vscode-vyper copied to clipboard

Extension does not check python environment for modules

Open PatrickAlphaC opened this issue 1 year ago • 3 comments
trafficstars

  1. Install snekmate, and add to a contract
pip install snekmate

my_contract.vy

from snekmate.tokens import erc20
  1. Compile with vyper command
vyper my_contract.vy

(it will compile) but the extension will not find snekmate Screenshot 2024-08-01 at 6 38 50 PM

PatrickAlphaC avatar Aug 01 '24 22:08 PatrickAlphaC

Ah, I needed to update the vyper executable in the settings.json. I think it would be good for it to showhow do like which vyper and have that be the path? I'm not sure how it's picking up the vyper executable right now.

I was able to fix this by adding a .vscode/settings.json like so:

{
    "vyper.command": "/my_virtual_env_path/.venv/bin/vyper",
}

PatrickAlphaC avatar Aug 01 '24 22:08 PatrickAlphaC

The extension simply calls vyper -f bytecode,..., so the problematic is rather which virtual env does VSCode uses for running extensions.

I haven't tried with venv but with pyenv, if there is a .python-version in your workspace specifying some virtual env, VSCode will use it for running extensions. Hence if you have installed vyper and snekmate in that virtual env, the extension will work fine without having to modify vyper.command since:

❯ which vyper
/Users/bob/.pyenv/shims/vyper

Example usage in the directory of the project:

pyenv virtualenv 3.11 temp1
pyenv local temp1
pip install vyper
pip install snekmate

trocher avatar Aug 19 '24 08:08 trocher

I have a work around, just update the settings.json to something "smarter".

Just customize the vyper command in the file.

{
    "files.exclude": {
        "**/__pycache__": true
    },
    "files.associations": {
        ".coveragerc": "toml"
    },
    "vyper.command": "vyper -p ./lib/github -p ./lib/pypi"
}

PatrickAlphaC avatar Nov 15 '24 23:11 PatrickAlphaC