MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / create_plugin_with_venv

Function create_plugin_with_venv

src/python/lfs_plugins/dev_setup.py:14–55  ·  view source on GitHub ↗

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 = "",
)

Source from the content-addressed store, hash-verified

12
13
14def 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
58def _uv_env(*, set_pythonhome: bool) -> dict:

Callers

nothing calls this directly

Calls 5

_venv_python_pathFunction · 0.85
_uv_envFunction · 0.85
_generate_vscode_configFunction · 0.85
create_pluginFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected