sum-cli 3.0.0__py3-none-any.whl → 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sum/cli.py +3 -3
- sum/commands/__init__.py +2 -2
- sum/commands/init.py +97 -15
- sum/commands/promote.py +29 -10
- sum/commands/setup.py +143 -0
- sum/setup/git_ops.py +69 -50
- sum/setup/orchestrator.py +2 -2
- sum/setup/scaffold.py +9 -12
- sum/setup/site_orchestrator.py +29 -4
- sum/site_config.py +129 -0
- sum/system_config.py +0 -37
- sum/utils/environment.py +2 -2
- sum/utils/validation.py +2 -2
- sum_cli-3.1.0.dist-info/METADATA +230 -0
- {sum_cli-3.0.0.dist-info → sum_cli-3.1.0.dist-info}/RECORD +19 -19
- sum/commands/run.py +0 -96
- sum/docs/USER_GUIDE.md +0 -663
- sum_cli-3.0.0.dist-info/METADATA +0 -127
- {sum_cli-3.0.0.dist-info → sum_cli-3.1.0.dist-info}/WHEEL +0 -0
- {sum_cli-3.0.0.dist-info → sum_cli-3.1.0.dist-info}/entry_points.txt +0 -0
- {sum_cli-3.0.0.dist-info → sum_cli-3.1.0.dist-info}/licenses/LICENSE +0 -0
- {sum_cli-3.0.0.dist-info → sum_cli-3.1.0.dist-info}/top_level.txt +0 -0
sum/commands/run.py
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"""Run command for starting SUM projects with virtualenv awareness."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import socket
|
|
7
|
-
import subprocess
|
|
8
|
-
|
|
9
|
-
import click
|
|
10
|
-
from sum.setup.venv import VenvManager
|
|
11
|
-
from sum.utils.environment import (
|
|
12
|
-
ExecutionMode,
|
|
13
|
-
detect_mode,
|
|
14
|
-
find_monorepo_root,
|
|
15
|
-
resolve_project_path,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def find_available_port(start_port: int = 8000, max_attempts: int = 10) -> int:
|
|
20
|
-
"""Find an available port starting from start_port.
|
|
21
|
-
|
|
22
|
-
Example:
|
|
23
|
-
port = find_available_port(8000, max_attempts=5)
|
|
24
|
-
# Returns the first available port between 8000 and 8004
|
|
25
|
-
"""
|
|
26
|
-
for port in range(start_port, start_port + max_attempts):
|
|
27
|
-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
28
|
-
try:
|
|
29
|
-
sock.bind(("127.0.0.1", port))
|
|
30
|
-
except OSError:
|
|
31
|
-
continue
|
|
32
|
-
return port
|
|
33
|
-
raise RuntimeError(
|
|
34
|
-
f"No available ports found in range {start_port}-{start_port + max_attempts - 1}"
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@click.command()
|
|
39
|
-
@click.argument("project", required=False)
|
|
40
|
-
@click.option(
|
|
41
|
-
"--port",
|
|
42
|
-
default=8000,
|
|
43
|
-
type=int,
|
|
44
|
-
help="Development server port (default: 8000)",
|
|
45
|
-
)
|
|
46
|
-
def run(project: str | None, port: int) -> None:
|
|
47
|
-
"""Start development server for a project."""
|
|
48
|
-
try:
|
|
49
|
-
project_path = resolve_project_path(project)
|
|
50
|
-
except FileNotFoundError as exc:
|
|
51
|
-
raise click.ClickException(str(exc)) from exc
|
|
52
|
-
project_name = project_path.name
|
|
53
|
-
mode = detect_mode(project_path)
|
|
54
|
-
|
|
55
|
-
venv_manager = VenvManager()
|
|
56
|
-
if not venv_manager.exists(project_path):
|
|
57
|
-
raise click.ClickException(
|
|
58
|
-
f"Virtualenv not found at {project_path / '.venv'}. Run 'sum init --full' or create manually."
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
python_exe = venv_manager.get_python_executable(project_path)
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
actual_port = find_available_port(port)
|
|
65
|
-
except RuntimeError as exc:
|
|
66
|
-
raise click.ClickException(str(exc)) from exc
|
|
67
|
-
|
|
68
|
-
if actual_port != port:
|
|
69
|
-
click.echo(f"⚠️ Port {port} in use, using {actual_port} instead")
|
|
70
|
-
|
|
71
|
-
click.echo(f"🚀 Starting {project_name}...")
|
|
72
|
-
click.echo()
|
|
73
|
-
click.echo(f"Using virtualenv: {project_path / '.venv'}")
|
|
74
|
-
click.echo(f"Mode: {mode.value}")
|
|
75
|
-
click.echo(f"Python: {python_exe}")
|
|
76
|
-
click.echo()
|
|
77
|
-
|
|
78
|
-
env = os.environ.copy()
|
|
79
|
-
if mode is ExecutionMode.MONOREPO:
|
|
80
|
-
repo_root = find_monorepo_root(project_path)
|
|
81
|
-
if repo_root is not None:
|
|
82
|
-
core_path = repo_root / "core"
|
|
83
|
-
existing = env.get("PYTHONPATH", "")
|
|
84
|
-
if existing:
|
|
85
|
-
env["PYTHONPATH"] = f"{existing}{os.pathsep}{core_path}"
|
|
86
|
-
else:
|
|
87
|
-
env["PYTHONPATH"] = str(core_path)
|
|
88
|
-
|
|
89
|
-
try:
|
|
90
|
-
subprocess.run(
|
|
91
|
-
[str(python_exe), "manage.py", "runserver", f"127.0.0.1:{actual_port}"],
|
|
92
|
-
cwd=project_path,
|
|
93
|
-
env=env,
|
|
94
|
-
)
|
|
95
|
-
except KeyboardInterrupt:
|
|
96
|
-
click.echo("\n👋 Server stopped")
|