Repository navigation
Expand file tree
/
Copy pathprepare_release.py
More file actions
279 lines (220 loc) · 8.51 KB
/
Copy pathprepare_release.py
File metadata and controls
279 lines (220 loc) · 8.51 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/env python3
"""
Release Preparation Script for Python Thinker
Cleans up repository and prepares release assets
"""
import os
import shutil
import zipfile
import json
from datetime import datetime
def clean_repository():
"""Clean up build artifacts and temporary files from repository"""
print("🧹 Cleaning repository...")
# Directories to remove
dirs_to_remove = [
"build",
"dist",
"__pycache__",
"PythonThinker_Portable",
".conda"
]
# Files to remove
files_to_remove = [
"PythonThinker.spec",
# Remove user session files (but keep demo files)
"thinking_session_00f7d99b_20250722_150745.txt",
"thinking_session_1bc28e80_20250722_162755.txt",
"thinking_session_49b52af3_20250722_162751.md",
"thinking_session_8e0d4bb3_20250722_150736.md",
"thoughts.json" # Remove any existing user data
]
# Remove directories
for dir_name in dirs_to_remove:
if os.path.exists(dir_name):
shutil.rmtree(dir_name)
print(f"✅ Removed directory: {dir_name}")
# Remove files
for file_name in files_to_remove:
if os.path.exists(file_name):
os.remove(file_name)
print(f"✅ Removed file: {file_name}")
print("✅ Repository cleaned!")
def create_release_structure():
"""Create proper release structure"""
print("📁 Creating release structure...")
# Create release directory
release_dir = "release"
if os.path.exists(release_dir):
shutil.rmtree(release_dir)
os.makedirs(release_dir)
# Create source code archive structure
source_files = [
"launcher.py",
"thinker_app.py",
"thinker_gui.py",
"build_standalone.bat",
"build_standalone.ps1",
"build_standalone.py",
"start_thinker.bat",
"start_thinker.ps1",
"requirements.txt",
"README.md",
"SETUP.md",
"STANDALONE_SETUP.md",
"demo_thoughts.json",
"workflow_demo.json",
".gitignore"
]
# Copy source files to release directory
source_dir = os.path.join(release_dir, "PythonThinker-Source")
os.makedirs(source_dir)
for file_name in source_files:
if os.path.exists(file_name):
shutil.copy2(file_name, source_dir)
print(f"✅ Copied to source: {file_name}")
return release_dir, source_dir
def build_executable_for_release():
"""Build the standalone executable for release"""
print("🔨 Building executable for release...")
# Run the build script
import subprocess
import sys
try:
# Use the Python build script for better control
result = subprocess.run([sys.executable, "build_standalone.py"],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ Executable built successfully!")
return True
else:
print(f"❌ Build failed: {result.stderr}")
return False
except Exception as e:
print(f"❌ Build error: {e}")
return False
def create_release_archives(release_dir):
"""Create ZIP archives for different release assets"""
print("📦 Creating release archives...")
version = datetime.now().strftime("%Y.%m.%d")
# 1. Source Code Archive
source_zip = f"PythonThinker-Source-v{version}.zip"
source_path = os.path.join(release_dir, "PythonThinker-Source")
if os.path.exists(source_path):
with zipfile.ZipFile(os.path.join(release_dir, source_zip), 'w', zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk(source_path):
for file in files:
file_path = os.path.join(root, file)
arc_name = os.path.relpath(file_path, source_path)
zf.write(file_path, arc_name)
print(f"✅ Created source archive: {source_zip}")
# 2. Portable Executable Archive
if os.path.exists("PythonThinker_Portable"):
portable_zip = f"PythonThinker-Portable-Windows-v{version}.zip"
with zipfile.ZipFile(os.path.join(release_dir, portable_zip), 'w', zipfile.ZIP_DEFLATED) as zf:
for root, dirs, files in os.walk("PythonThinker_Portable"):
for file in files:
file_path = os.path.join(root, file)
arc_name = os.path.relpath(file_path, ".")
zf.write(file_path, arc_name)
print(f"✅ Created portable archive: {portable_zip}")
# 3. Standalone Executable Only
if os.path.exists("dist/PythonThinker.exe"):
exe_zip = f"PythonThinker-Executable-v{version}.zip"
with zipfile.ZipFile(os.path.join(release_dir, exe_zip), 'w', zipfile.ZIP_DEFLATED) as zf:
zf.write("dist/PythonThinker.exe", "PythonThinker.exe")
print(f"✅ Created executable archive: {exe_zip}")
return version
def create_release_notes(release_dir, version):
"""Create release notes"""
print("📝 Creating release notes...")
release_notes = f"""# Python Thinker v{version} Release Notes
## 🎉 What's New
Python Thinker is a comprehensive tool to help you organize thoughts, brainstorm ideas, and structure your thinking process.
## 📦 Release Assets
### For End Users (No Python Required)
- **`PythonThinker-Portable-Windows-v{version}.zip`** - Complete portable package
- Extract and run `Start_PythonThinker.bat`
- No installation required!
- Works on Windows 7+
- **`PythonThinker-Executable-v{version}.zip`** - Just the executable
- Single file: `PythonThinker.exe`
- Minimal download size
### For Developers (Python Required)
- **`PythonThinker-Source-v{version}.zip`** - Complete source code
- All Python files and build scripts
- Run with: `python launcher.py`
- Build your own executable
## ✨ Features
- 📚 **Multiple Thinking Sessions** - Organize thoughts by topic
- 💭 **Rich Thought Management** - Categories, priorities, and tags
- 🧠 **Brainstorming Mode** - Rapid idea capture
- ✅ **Progress Tracking** - Mark thoughts as completed
- 📄 **Export Capabilities** - TXT and Markdown formats
- 🖥️ **Dual Interface** - CLI and GUI versions
- 💾 **Data Persistence** - Automatic saving
## 🚀 Quick Start
### Portable Version (Recommended)
1. Download `PythonThinker-Portable-Windows-v{version}.zip`
2. Extract to any folder
3. Double-click `Start_PythonThinker.bat`
4. Choose CLI (1) or GUI (2) interface
5. Start organizing your thoughts!
### Source Version
1. Download `PythonThinker-Source-v{version}.zip`
2. Extract and open terminal in folder
3. Run: `python launcher.py`
4. Requires Python 3.7+
## 🛠️ System Requirements
### Portable Version
- Windows 7 or later
- No additional software required
### Source Version
- Python 3.7+
- tkinter (usually included)
## 📖 Documentation
- `README.md` - Complete user guide
- `STANDALONE_SETUP.md` - Build instructions
- `PORTABLE_README.md` - Portable version guide
## 🐛 Bug Reports & Feature Requests
Please report issues on the GitHub repository.
## 📄 License
Open source - modify and distribute freely.
---
*Happy thinking! 🧠*
"""
with open(os.path.join(release_dir, f"RELEASE_NOTES_v{version}.md"), "w", encoding="utf-8") as f:
f.write(release_notes)
print(f"✅ Created release notes: RELEASE_NOTES_v{version}.md")
def main():
"""Main release preparation process"""
print("🚀 Python Thinker Release Preparation")
print("=" * 40)
# Step 1: Clean repository
clean_repository()
print()
# Step 2: Create release structure
release_dir, source_dir = create_release_structure()
print()
# Step 3: Build executable
if build_executable_for_release():
print()
# Step 4: Create archives
version = create_release_archives(release_dir)
print()
# Step 5: Create release notes
create_release_notes(release_dir, version)
print()
print("🎉 Release preparation complete!")
print(f"\n📁 Check the '{release_dir}' folder for:")
print("1. Source code archive")
print("2. Portable executable archive")
print("3. Standalone executable archive")
print("4. Release notes")
print("\n🚀 Ready for GitHub release!")
return True
else:
print("❌ Release preparation failed during build step")
return False
if __name__ == "__main__":
main()