Monday 11 May 2020

VSCode Dev environment setup

venv

python3 -m venv .venv
source .venv/bin/activate
pip install -r ./app-server/src/requirements-customer.txt
pip install -r ./app-server/src/tests/requirements.txt
deactivate
pip freeze | xargs pip uninstall -y

vscode

command + P: Python: Select Interpreter選預設的等建出settings.json後再改成venv裡面的
  • .vscode/settins.json
    {
      "python.pythonPath"".venv\\Scripts\\python.exe"
    }
command + P: Python: Select Linter選pylint
  • .vscode/settins.json
    {
      "python.pythonPath"".venv\\Scripts\\python.exe",
      "python.linting.enabled"true,
      "python.linting.pylintEnabled"true
    }
    # https://code.visualstudio.com/docs/python/linting#_enable-linters
    # vscode還是會跳出說要安裝pylint, 裝完後就可以ok (不過不知道vscode把pylint裝到哪邊, 因為requirement不需要列, pip freeze也沒有看到)
command + P: Python: Configure Tests pytest
  • {
        "python.pythonPath"".venv/bin/python3",
        "python.linting.pylintEnabled"true,
        "python.linting.enabled"true,
        "python.testing.pytestEnabled"true,
        "python.testing.nosetestsEnabled"false,
        "python.testing.pytestArgs": [
            "app-server"
        ]
    }

No comments:

Post a Comment