|
| 1 | +import platform |
1 | 2 | import shutil |
2 | 3 | import subprocess |
3 | 4 | import zipfile |
4 | 5 | from pathlib import Path |
5 | 6 |
|
6 | 7 | import requests |
| 8 | +import packaging_utils |
7 | 9 |
|
8 | 10 | # Constants |
9 | | -WEZTERM_VERSION = "20240203-110809-5046fc22" |
| 11 | +WEZTERM_VERSION = packaging_utils.get_wezterm_version() |
10 | 12 | WEZTERM_FOLDERNAME = f"WezTerm-windows-{WEZTERM_VERSION}" |
11 | 13 | WEZTERM_URL = f"https://github.com/wezterm/wezterm/releases/download/{WEZTERM_VERSION}/{WEZTERM_FOLDERNAME}.zip" |
12 | 14 |
|
13 | 15 | # Paths |
14 | 16 | project_root = Path(__file__).parent |
15 | | -base_path = Path.cwd() |
16 | 17 | vendored_dir = base_path / "_vendored" |
17 | | -wezterm_extracted_dir = vendored_dir / f"WezTerm-windows-{WEZTERM_VERSION}" |
18 | | -wezterm_zip_path = vendored_dir / f"{WEZTERM_FOLDERNAME}.zip" |
19 | 18 |
|
20 | | -# Step 1: Download and extract WezTerm if missing |
21 | | -if not wezterm_extracted_dir.exists(): |
22 | | - print("⬇ Downloading WezTerm...") |
23 | | - vendored_dir.mkdir(parents=True, exist_ok=True) |
24 | | - with requests.get(WEZTERM_URL, stream=True) as response: |
25 | | - response.raise_for_status() |
26 | | - with open(wezterm_zip_path, "wb") as f: |
27 | | - for chunk in response.iter_content(8192): |
28 | | - f.write(chunk) |
| 19 | +packaging_utils.download_wezterm(vendored_dir, WEZTERM_FOLDERNAME) |
29 | 20 |
|
30 | | - print("📦 Extracting WezTerm...") |
31 | | - with zipfile.ZipFile(wezterm_zip_path, "r") as zipf: |
32 | | - zipf.extractall(vendored_dir) |
33 | | - wezterm_zip_path.unlink() # Optional: clean up ZIP |
34 | | - print("✅ WezTerm ready.") |
35 | | -else: |
36 | | - print("✅ WezTerm already present. Skipping download.") |
| 21 | +if (build_path := project_root / "build").exists(): |
| 22 | + shutil.rmtree(build_path) |
| 23 | + |
| 24 | +if (dist_path := project_root / "dist").exists(): |
| 25 | + shutil.rmtree(dist_path) |
| 26 | + |
| 27 | +# Step 2: Run PyInstaller builds |
| 28 | +subprocess.run(f"pyinstaller {project_root / 'datashuttle.spec'}", shell=True) |
| 29 | +subprocess.run(f"pyinstaller {project_root / 'terminal_launcher.spec'}", shell=True) |
37 | 30 |
|
38 | 31 | shutil.copy( |
39 | 32 | base_path / "wezterm_config.lua", vendored_dir / WEZTERM_FOLDERNAME |
40 | 33 | ) |
41 | 34 |
|
42 | | -# Step 2: Run PyInstaller builds |
43 | | -subprocess.run(f"pyinstaller {project_root / 'datashuttle.spec'}") |
44 | | -subprocess.run(f"pyinstaller {project_root / 'terminal_launcher.spec'}") |
45 | | - |
46 | 35 | # Step 3: Copy WezTerm into dist/_vendored |
47 | 36 | dist_dir = base_path / "dist" |
48 | 37 | terminal_launcher_dist_dir = dist_dir / "terminal_launcher" |
|
63 | 52 | shutil.copy2(item, target) |
64 | 53 |
|
65 | 54 | shutil.rmtree(terminal_launcher_dist_dir) |
| 55 | + |
0 commit comments