Skip to content

Instantly share code, notes, and snippets.

@arafatamim
Created May 19, 2020 02:58
Show Gist options
  • Save arafatamim/351d0c0630209716015bea1ef8d9a7d8 to your computer and use it in GitHub Desktop.
Save arafatamim/351d0c0630209716015bea1ef8d9a7d8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import json
import subprocess
from pathlib import Path
venv_path = subprocess.check_output("poetry env info --path".split())
venv_path = venv_path.decode("UTF-8")
settings = dict()
Path(".vscode").mkdir(parents=True, exist_ok=True)
Path(".vscode/settings.json").touch()
with open(".vscode/settings.json", "r") as f:
settings = json.load(f)
settings["python.pythonPath"] = venv_path
with open(".vscode/settings.json", "w") as f:
json.dump(settings, f, sort_keys=True, indent=4)
print(json.dumps(settings, sort_keys=True, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment