feat: dynamic Python version lookup, README cleanup

- Query python.org API for latest 3.13/3.14 patch instead of hardcoding
- Fall back to hardcoded version if API is unreachable
- Wrap Table of Contents in collapsible <details> block
- Simplify CPU benchmark link formatting in README
This commit is contained in:
Tieu Long committed 2026-03-21 15:57:29 +07:00
1 parent 4165b0a01f
commit 55fb2143a0
4 files changed
+125 -120

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Install xorriso
run: |
@@ -33,7 +33,7 @@ jobs:
bash Make_ISO.command
- name: Upload artifact
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v7
with:
name: OpenCore-ISO
path: ~/Desktop/LongQT-OpenCore*.iso
BIN
View File
Binary file not shown.
+116 -115
View File
@@ -8,26 +8,15 @@
set -e
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
NC='\033[0m'
# Function to print colored messages
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running as root, if not, re-execute with sudo
if [ "$EUID" -ne 0 ]; then
echo ""
echo -e "${YELLOW}[INFO]${NC} Administrator privileges required..."
@@ -35,176 +24,190 @@ if [ "$EUID" -ne 0 ]; then
exit
fi
# Get macOS version
get_macos_version() {
sw_vers -productVersion
}
# Determine Python version and download URL based on macOS version
get_latest_version() {
local branch=$1
local fallback=$2
local api_url="https://www.python.org/api/v2/downloads/release/?version=3&pre_release=false&is_published=true"
local raw=""
if command -v curl &> /dev/null; then
raw=$(curl -sf --connect-timeout 10 --max-time 20 "$api_url" 2>/dev/null || true)
elif command -v wget &> /dev/null; then
raw=$(wget -qO- --timeout=20 "$api_url" 2>/dev/null || true)
fi
if [ -z "$raw" ]; then
print_warning "Could not reach python.org API. Using fallback version: $fallback"
echo "$fallback"
return
fi
local latest=""
latest=$(echo "$raw" \
| grep -o '"name":"Python [^"]*"' \
| sed 's/"name":"Python //;s/"//' \
| grep -E "^${branch//./\\.}\\.[0-9]+$" \
| sort -t. -k3 -n \
| tail -n 1)
if [ -z "$latest" ]; then
print_warning "Could not parse version for branch ${branch}. Using fallback: $fallback"
echo "$fallback"
else
echo "$latest"
fi
}
determine_python_version() {
local macos_version=$1
local major=$(echo "$macos_version" | cut -d. -f1)
local minor=$(echo "$macos_version" | cut -d. -f2)
local major
local minor
major=$(echo "$macos_version" | cut -d. -f1)
minor=$(echo "$macos_version" | cut -d. -f2)
if [ "$major" -eq 10 ]; then
if [ "$minor" -ge 15 ]; then
# macOS 10.15
PYTHON_VERSION="3.14.0"
PYTHON_PKG="python-3.14.0-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.14.0/python-3.14.0-macos11.pkg"
print_info "Fetching latest Python 3.14 release..."
PYTHON_VERSION=$(get_latest_version "3.14" "3.14.3")
PYTHON_PKG="python-${PYTHON_VERSION}-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_PKG}"
elif [ "$minor" -ge 13 ] && [ "$minor" -le 14 ]; then
# macOS 10.13 to 10.14
PYTHON_VERSION="3.13.9"
PYTHON_PKG="python-3.13.9-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.13.9/python-3.13.9-macos11.pkg"
print_info "Fetching latest Python 3.13 release..."
PYTHON_VERSION=$(get_latest_version "3.13" "3.13.12")
PYTHON_PKG="python-${PYTHON_VERSION}-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_PKG}"
elif [ "$minor" -ge 9 ] && [ "$minor" -le 12 ]; then
# macOS 10.9 to 10.12
# EOL — 3.9.13 is the last release with a macosx10.9 pkg
PYTHON_VERSION="3.9.13"
PYTHON_PKG="python-3.9.13-macosx10.9.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.9.13/python-3.9.13-macosx10.9.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.9.13/${PYTHON_PKG}"
elif [ "$minor" -ge 6 ] && [ "$minor" -le 8 ]; then
# macOS 10.6 to 10.8
PYTHON_VERSION="3.6.6"
PYTHON_PKG="python-3.6.6-macosx10.6.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.6.6/python-3.6.6-macosx10.6.pkg"
# EOL — 3.6.8 is the last release with a macosx10.6 pkg
PYTHON_VERSION="3.6.8"
PYTHON_PKG="python-3.6.8-macosx10.6.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.6.8/${PYTHON_PKG}"
else
print_error "Unsupported macOS version: $macos_version"
exit 1
fi
elif [ "$major" -ge 11 ]; then
# macOS 11 (Big Sur) and later
PYTHON_VERSION="3.14.0"
PYTHON_PKG="python-3.14.0-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/3.14.0/python-3.14.0-macos11.pkg"
print_info "Fetching latest Python 3.14 release..."
PYTHON_VERSION=$(get_latest_version "3.14" "3.14.3")
PYTHON_PKG="python-${PYTHON_VERSION}-macos11.pkg"
DOWNLOAD_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_PKG}"
else
print_error "Unsupported macOS version: $macos_version"
exit 1
fi
}
# Check if installer exists in current directory
check_local_installer() {
local pattern=$1
local script_dir="$(cd "$(dirname "$0")" && pwd)"
# Use ls and grep to find matching files (more compatible)
local found_file=""
# First, try to find exact match
if [ -f "$script_dir/$PYTHON_PKG" ]; then
echo "$script_dir/$PYTHON_PKG"
return 0
fi
# Then try pattern matching with ls
found_file=$(ls -1 "$script_dir" 2>/dev/null | grep -E "^python-${PYTHON_VERSION}.*\.pkg$" | head -n 1)
if [ -n "$found_file" ]; then
echo "$script_dir/$found_file"
return 0
fi
# Also check current working directory if different from script dir
local current_dir="$(pwd)"
if [ "$current_dir" != "$script_dir" ]; then
if [ -f "$current_dir/$PYTHON_PKG" ]; then
echo "$current_dir/$PYTHON_PKG"
find_pkg_in_dir() {
local dir=$1
local f
for f in "$dir"/python-"${PYTHON_VERSION}"*.pkg; do
if [ -f "$f" ]; then
echo "$f"
return 0
fi
found_file=$(ls -1 "$current_dir" 2>/dev/null | grep -E "^python-${PYTHON_VERSION}.*\.pkg$" | head -n 1)
if [ -n "$found_file" ]; then
echo "$current_dir/$found_file"
done
return 1
}
check_local_installer() {
local script_dir
local current_dir
script_dir="$(cd "$(dirname "$0")" && pwd)"
current_dir="$(pwd)"
local found
if found=$(find_pkg_in_dir "$script_dir"); then
echo "$found"
return 0
fi
if [ "$current_dir" != "$script_dir" ]; then
if found=$(find_pkg_in_dir "$current_dir"); then
echo "$found"
return 0
fi
fi
return 1
}
# Download installer
download_installer() {
local url=$1
local output=$2
print_info "Downloading Python installer from: $url"
if command -v curl &> /dev/null; then
if curl -L -o "$output" "$url" --connect-timeout 30 --max-time 600; then
return 0
else
return 1
fi
curl -L -o "$output" "$url" --connect-timeout 30 --max-time 600
elif command -v wget &> /dev/null; then
if wget -O "$output" "$url" --timeout=30; then
return 0
else
return 1
fi
wget -O "$output" "$url" --timeout=30
else
print_error "Neither curl nor wget found. Cannot download installer."
return 1
fi
}
# Install Python silently
install_python() {
local pkg_path=$1
print_info "Installing Python from: $pkg_path"
if [ ! -f "$pkg_path" ]; then
print_error "Installer file not found: $pkg_path"
exit 1
fi
# Silent installation using installer command
if sudo installer -pkg "$pkg_path" -target / -verbose; then
print_info "Python installed successfully!"
return 0
else
print_error "Installation failed!"
return 1
fi
}
# Main installation process
main() {
print_info "macOS Python Silent Installer"
echo ""
# Get macOS version
local MACOS_VERSION
MACOS_VERSION=$(get_macos_version)
print_info "Detected macOS version: $MACOS_VERSION"
# Determine appropriate Python version
determine_python_version "$MACOS_VERSION"
print_info "Target Python version: $PYTHON_VERSION"
print_info "Installer package: $PYTHON_PKG"
echo ""
# Check if installer exists locally
print_info "Checking for local installer..."
print_info "Script directory: $(cd "$(dirname "$0")" && pwd)"
print_info "Current directory: $(pwd)"
LOCAL_PKG=""
# Extract version pattern for search (e.g., "python-3.9.13*")
VERSION_PATTERN="python-${PYTHON_VERSION}*"
if LOCAL_PKG=$(check_local_installer "$VERSION_PATTERN"); then
local INSTALLER_PATH
local LOCAL_PKG
if LOCAL_PKG=$(check_local_installer); then
print_info "Found local installer: $LOCAL_PKG"
INSTALLER_PATH="$LOCAL_PKG"
else
print_warning "Local installer not found. Attempting to download..."
# Save to current user's Downloads folder
DOWNLOADS_DIR="$HOME/Downloads"
local DOWNLOADS_DIR="$HOME/Downloads"
INSTALLER_PATH="$DOWNLOADS_DIR/$PYTHON_PKG"
print_info "Will save installer to: $INSTALLER_PATH"
if ! download_installer "$DOWNLOAD_URL" "$INSTALLER_PATH"; then
print_error "Download failed!"
echo ""
@@ -217,19 +220,18 @@ main() {
print_info "Looking for: $PYTHON_PKG"
exit 1
fi
print_info "Download completed successfully!"
fi
echo ""
# Install Python
if install_python "$INSTALLER_PATH"; then
echo ""
print_info "Installation complete!"
# Verify installation
if command -v python3 &> /dev/null; then
local INSTALLED_VERSION
INSTALLED_VERSION=$(python3 --version 2>&1)
print_info "Installed: $INSTALLED_VERSION"
fi
@@ -238,7 +240,6 @@ main() {
fi
}
# Run main function
main
exit 0
+7 -3
View File
@@ -9,7 +9,10 @@ Supports every Intel-based macOS release from **[Mac OS X 10.4 Tiger](https://do
> This is likely the best way to run macOS on AMD hardware while retaining full hypervisor access for other VMs.
> Also overcomes a lot of AMD CPU limitations listed on [Dortania guide](https://dortania.github.io/Anti-Hackintosh-Buyers-Guide/CPU.html#cpus-to-avoid).
## Table of Contents
---
<details>
<summary>Table of Contents</summary>
- [Download](#download)
- [Quick Start Guide](#quick-start-guide)
@@ -29,6 +32,7 @@ Supports every Intel-based macOS release from **[Mac OS X 10.4 Tiger](https://do
- [Credits](#credits)
- [License & Attribution](#license--attribution)
- [Disclaimer](#disclaimer)
</details>
---
@@ -69,7 +73,7 @@ Open the Proxmox VE web interface and create a new VM.
### 4. System
* **Machine Type**: q35 *(if using **i440fx**, add `+invtsc` CPU flag, see [cpu-models.conf](https://github.com/LongQT-sea/OpenCore-ISO/blob/main/cpu-models.conf))*
* **Machine Type**: q35
* **BIOS**: OVMF (UEFI)
* **Add EFI Disk**: [✓] Enabled
* **Pre-Enroll Keys**: [✗] Untick to disable Secure Boot
@@ -149,7 +153,7 @@ Choose based on your hardware (`power of 2`): 1 / 2 / 4 / 8 / 16 / 32 / 64
> ```
> qm set [VMID] --args "-cpu Skylake-Client-v4,+vmx"
> ```
> * Avoid using [`host`](https://browser.geekbench.com/v6/cpu/14313138) passthrough CPU types[^hostcpu] — they can be **~30% slower (single-core)** and **~44% slower (multi-core)** compared to [`recommended`](https://browser.geekbench.com/v6/cpu/14205183) CPU types.
> * Avoid using `host` passthrough CPU types[^hostcpu] — they can be [**~30% slower (single-core)** and **~44% slower (multi-core)**](https://browser.geekbench.com/v6/cpu/compare/14205183?baseline=14313138) compared to recommended CPU types.
For more details, see [QEMU CPU Guide – macOS Guests](https://github.com/LongQT-sea/qemu-cpu-guide?#macos-guests).