-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup-python.sh
More file actions
executable file
·123 lines (104 loc) · 3.23 KB
/
Copy pathsetup-python.sh
File metadata and controls
executable file
·123 lines (104 loc) · 3.23 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
#!/bin/bash
# ClassTop Python Setup Script for macOS
# Downloads and configures CPython for standalone build
set -e # Exit on error
echo "🐍 ClassTop Python Setup Script"
echo "================================"
echo ""
# Configuration
PYTHON_VERSION="3.13"
ARCH="aarch64" # Apple Silicon
OS="apple-darwin"
TARBALL_NAME="cpython-${PYTHON_VERSION}*-${ARCH}-${OS}-install_only_stripped.tar.gz"
PYEMBED_DIR="./src-tauri/pyembed"
PYTHON_DIR="${PYEMBED_DIR}/python"
# GitHub release URL
RELEASES_URL="https://github.com/indygreg/python-build-standalone/releases"
echo "📋 Configuration:"
echo " Python Version: ${PYTHON_VERSION}"
echo " Architecture: ${ARCH}"
echo " Platform: ${OS}"
echo ""
# Check if already installed
if [ -f "${PYTHON_DIR}/bin/python3" ]; then
echo "✅ Python already installed at ${PYTHON_DIR}"
echo ""
read -p "Reinstall? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping installation."
exit 0
fi
echo "🗑️ Removing existing installation..."
rm -rf "${PYEMBED_DIR}"
fi
# Create directory
echo "📁 Creating directory: ${PYEMBED_DIR}"
mkdir -p "${PYEMBED_DIR}"
cd "${PYEMBED_DIR}"
# Find latest release
echo "🔍 Finding latest Python ${PYTHON_VERSION} release..."
echo ""
echo "Please visit: ${RELEASES_URL}"
echo "Download the file matching: ${TARBALL_NAME}"
echo ""
echo "After downloading, place it in: $(pwd)"
echo ""
read -p "Press Enter after you've downloaded the file..."
# Find the downloaded tarball
TARBALL=$(ls cpython-${PYTHON_VERSION}*-${ARCH}-${OS}-install_only_stripped.tar.gz 2>/dev/null | head -n 1)
if [ -z "$TARBALL" ]; then
echo ""
echo "❌ Error: Tarball not found in current directory"
echo "Expected pattern: ${TARBALL_NAME}"
echo "Current directory: $(pwd)"
echo ""
ls -la
exit 1
fi
echo "✅ Found tarball: $TARBALL"
echo ""
# Extract tarball
echo "📦 Extracting Python..."
tar -xzf "$TARBALL"
# Check extraction result
if [ ! -d "python" ]; then
echo "❌ Error: Extraction failed - 'python' directory not found"
exit 1
fi
echo "✅ Extraction complete"
echo ""
# Find libpython dylib
LIBPYTHON=$(ls python/lib/libpython${PYTHON_VERSION}*.dylib 2>/dev/null | head -n 1)
if [ -z "$LIBPYTHON" ]; then
echo "⚠️ Warning: libpython dylib not found, trying to locate..."
LIBPYTHON=$(find python/lib -name "libpython*.dylib" | head -n 1)
fi
# Patch install_name if dylib found
if [ -n "$LIBPYTHON" ]; then
DYLIB_NAME=$(basename "$LIBPYTHON")
echo "🔧 Patching install_name for: $DYLIB_NAME"
install_name_tool -id "@rpath/$DYLIB_NAME" "$LIBPYTHON"
echo "✅ Patching complete"
else
echo "⚠️ Warning: Could not find libpython dylib to patch"
echo " This may cause runtime issues"
fi
echo ""
echo "🎉 Python setup complete!"
echo ""
echo "📁 Python installed at: ${PYTHON_DIR}"
echo "🐍 Python binary: ${PYTHON_DIR}/bin/python3"
echo ""
# Verify installation
if [ -f "${PYTHON_DIR}/bin/python3" ]; then
PYTHON_PATH="${PYTHON_DIR}/bin/python3"
echo "✅ Verification:"
echo " Path: $PYTHON_PATH"
$PYTHON_PATH --version
echo ""
echo "🚀 You can now run: ./build.sh"
else
echo "❌ Error: Python binary not found after installation"
exit 1
fi