This repository was archived by the owner on Nov 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_ccache.py
More file actions
80 lines (70 loc) · 2.77 KB
/
setup_ccache.py
File metadata and controls
80 lines (70 loc) · 2.77 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
#!/usr/bin/env python3
"""
Script to manually download and setup ccache for Nuitka
"""
import os
import urllib.request
import zipfile
import shutil
from pathlib import Path
def setup_ccache():
# Get the username
username = os.getenv('USER')
if not username:
print("Could not determine username")
return False
# Define paths
version="4.2.1"
ccache_version = f"v{version}"
ccache_url = f"https://nuitka.net/ccache/{ccache_version}/ccache-{version}.zip"
cache_dir = f"/Users/{username}/Library/Caches/Nuitka/downloads/ccache/{ccache_version}"
zip_path = os.path.join(cache_dir, f"ccache-{version}.zip")
print(f"Setting up ccache {ccache_version}")
print(f"Cache directory: {cache_dir}")
# Create directories if they don't exist
os.makedirs(cache_dir, exist_ok=True)
if os.path.exists(zip_path):
os.remove(zip_path)
# Download ccache
if not os.path.exists(zip_path):
print(f"Downloading ccache from {ccache_url}")
try:
# Create an unverified context for SSL to bypass certificate issues
import ssl
ssl_context = ssl._create_unverified_context()
# Download using the context
with urllib.request.urlopen(ccache_url, context=ssl_context) as response, \
open(zip_path, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
print("Download completed successfully")
# Set execute permission for the zip file
os.chmod(zip_path, 0o755)
#解压zip文件
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(cache_dir)
except Exception as e:
print(f"Failed to download ccache: {e}")
print("\nManual setup instructions:")
print("1. Download ccache manually from a browser:")
print(f" URL: {ccache_url}")
print(f"2. Save the file as 'ccache-{ccache_version}.zip'")
print(f"3. Place it in this directory: {cache_dir}")
print("4. Extract the contents of the zip file in the same directory")
print("\nAlternatively, you can skip ccache setup and proceed with the build.")
return False
else:
print("ccache zip file already exists")
# Extract the zip file
try:
print("Extracting ccache...")
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(cache_dir)
print("Extraction completed")
except FileExistsError:
print("ccache already exists")
return True
except Exception as e:
print(f"Failed to extract ccache: {e}")
return False
print("ccache setup completed successfully")
return True