Repository navigation
Expand file tree
/
Copy pathbuild_standalone.py
More file actions
137 lines (121 loc) · 3.57 KB
/
Copy pathbuild_standalone.py
File metadata and controls
137 lines (121 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python3
"""Build a standalone deepctl binary for testing system installations."""
import importlib.util
import shutil
import subprocess
import sys
from pathlib import Path
def build_standalone() -> None:
"""Build a standalone deepctl binary using PyInstaller."""
# Check if we're in the right directory
if not Path("pyproject.toml").exists():
print("❌ Please run this script from the deepctl root directory")
sys.exit(1)
print("🔨 Building standalone deepctl binary...")
# Install PyInstaller if needed
if importlib.util.find_spec("PyInstaller") is None:
print("📦 Installing PyInstaller...")
subprocess.run(
[sys.executable, "-m", "pip", "install", "pyinstaller"], check=True
)
# First, build the package to ensure everything is up to date
print("📦 Building deepctl package...")
subprocess.run(["make", "build"], check=True)
# Create a temporary directory for the build
build_dir = Path("build_standalone")
build_dir.mkdir(exist_ok=True)
# Create a simple spec file for PyInstaller
spec_content = """
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['../src/deepctl/main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[
'deepctl',
'deepctl_core',
'deepctl_cmd_usage',
'deepctl_cmd_transcribe',
'deepctl_cmd_plugin',
'deepctl_cmd_projects',
'deepctl_cmd_mcp',
'deepctl_cmd_login',
'deepctl_cmd_debug',
'deepctl_cmd_debug_audio',
'deepctl_cmd_debug_browser',
'deepctl_cmd_debug_network',
'deepctl_cmd_update',
'deepctl_shared_utils',
'click',
'rich',
'httpx',
'keyring',
'pydantic',
'deepgram',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='deepctl',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
"""
spec_file = build_dir / "deepctl.spec"
spec_file.write_text(spec_content)
# Run PyInstaller
print("🏗️ Running PyInstaller...")
subprocess.run(
[
sys.executable,
"-m",
"PyInstaller",
"--clean",
"--onefile",
"--name",
"deepctl",
"--distpath",
"dist_standalone",
"--workpath",
str(build_dir / "work"),
"--specpath",
str(build_dir),
str(spec_file),
],
check=True,
)
# Clean up build directory
shutil.rmtree(build_dir)
print("\n✅ Standalone binary built successfully!")
print(f"📍 Binary location: {Path('dist_standalone/deepctl').absolute()}")
print("\n🧪 To test the standalone binary:")
print(" ./dist_standalone/deepctl --version")