Create plugin with venv and VS Code configuration. Returns plugin path.
(
name: str,
*,
uv_path: str,
python_path: str,
typings_dir: str = "",
site_packages_dir: str = "",
)
| 12 | |
| 13 | |
| 14 | def create_plugin_with_venv( |
| 15 | name: str, |
| 16 | *, |
| 17 | uv_path: str, |
| 18 | python_path: str, |
| 19 | typings_dir: str = "", |
| 20 | site_packages_dir: str = "", |
| 21 | ) -> str: |
| 22 | """Create plugin with venv and VS Code configuration. Returns plugin path.""" |
| 23 | plugin_dir = create_plugin(name) |
| 24 | |
| 25 | assert uv_path, "UV path not provided" |
| 26 | assert python_path, "Python path not provided" |
| 27 | |
| 28 | venv_path = plugin_dir / ".venv" |
| 29 | venv_python = _venv_python_path(venv_path) |
| 30 | |
| 31 | venv_cmd = [ |
| 32 | uv_path, |
| 33 | "venv", |
| 34 | str(venv_path), |
| 35 | "--python", |
| 36 | python_path, |
| 37 | "--no-managed-python", |
| 38 | "--no-python-downloads", |
| 39 | ] |
| 40 | subprocess.run(venv_cmd, capture_output=True, text=True, check=True, env=_uv_env(set_pythonhome=True)) |
| 41 | |
| 42 | sync_cmd = [ |
| 43 | uv_path, |
| 44 | "sync", |
| 45 | "--project", |
| 46 | str(plugin_dir), |
| 47 | "--python", |
| 48 | str(venv_python), |
| 49 | "--no-managed-python", |
| 50 | "--no-python-downloads", |
| 51 | ] |
| 52 | subprocess.run(sync_cmd, capture_output=True, text=True, check=True, env=_uv_env(set_pythonhome=False)) |
| 53 | |
| 54 | _generate_vscode_config(plugin_dir, venv_path, typings_dir, site_packages_dir) |
| 55 | return str(plugin_dir) |
| 56 | |
| 57 | |
| 58 | def _uv_env(*, set_pythonhome: bool) -> dict: |
nothing calls this directly
no test coverage detected