-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpip_install_mac_patch.sh
More file actions
executable file
·143 lines (116 loc) · 4.55 KB
/
pip_install_mac_patch.sh
File metadata and controls
executable file
·143 lines (116 loc) · 4.55 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
#!/bin/bash
# pip_install_mac.sh - Temporary workaround for meson-python duplicate RPATH bug on macOS
set -e
# Color codes for output
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo -e "${YELLOW}"
echo "========================================================================="
echo " TEMPORARY INSTALLATION WORKAROUND"
echo "========================================================================="
echo -e "${NC}"
echo ""
echo -e "${YELLOW}WARNING:${NC} This script applies a temporary patch to fix a known issue with"
echo "meson-python that causes duplicate RPATH entries in built Python extensions"
echo "on macOS, preventing module imports."
echo ""
echo "This workaround will:"
echo " 1. Install fourdst using pip"
echo " 2. Locate the installed extension module"
echo " 3. Remove duplicate RPATH entries using install_name_tool"
echo ""
echo "This is a temporary solution while the meson-python team resolves the"
echo "duplicate RPATH bug. For more information, see:"
echo " https://github.com/mesonbuild/meson-python/issues/813"
echo ""
echo -e "${YELLOW}Do you understand and wish to continue? [y/N]${NC} "
read -r response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo -e "${RED}Installation cancelled.${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}Step 1: Finding current Python environment...${NC}"
# Get the current Python executable
PYTHON_BIN=$(which python3)
if [ -z "$PYTHON_BIN" ]; then
echo -e "${RED}Error: python3 not found in PATH${NC}"
exit 1
fi
echo "Using Python: $PYTHON_BIN"
PYTHON_VERSION=$($PYTHON_BIN --version)
echo "Python version: $PYTHON_VERSION"
# Get site-packages directory
SITE_PACKAGES=$($PYTHON_BIN -c "import site; print(site.getsitepackages()[0])")
echo "Site packages: $SITE_PACKAGES"
echo ""
echo -e "${GREEN}Step 2: Installing fourdst with pip...${NC}"
$PYTHON_BIN -m pip install . -v --no-build-isolation
if [ $? -ne 0 ]; then
echo -e "${RED}Error: pip install failed${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}Step 3: Locating installed gridfire extension module...${NC}"
# Find the .so file
SO_FILE=$(find "$SITE_PACKAGES/gridfire" -name "_gridfire.cpython-*-darwin.so" 2>/dev/null | head -n 1)
if [ -z "$SO_FILE" ]; then
echo -e "${RED}Error: Could not find _gridfire.cpython-*-darwin.so in $SITE_PACKAGES/gridfire${NC}"
echo "Installation may have failed or the file is in an unexpected location."
exit 1
fi
echo "Found gridfire extension module: $SO_FILE"
echo ""
echo -e "${GREEN}Step 4: Running RPATH fix script for gridfire extension module...${NC}"
# Check if fix_rpath.py exists
FIX_SCRIPT="build-python/fix_rpaths.py"
if [ ! -f "$FIX_SCRIPT" ]; then
echo -e "${RED}Error: $FIX_SCRIPT not found${NC}"
echo "Please ensure you're running this script from the project root directory."
exit 1
fi
# Run the fix script
$PYTHON_BIN "$FIX_SCRIPT" "$SO_FILE"
if [ $? -ne 0 ]; then
echo -e "${RED}Error: RPATH fix script failed for gridfire extension module${NC}"
exit 1
fi
echo -e "${GREEN}Step 5: Locating installed fourdst extension module...${NC}"
# Find the .so file
SO_FILE=$(find "$SITE_PACKAGES/fourdst" -name "_phys.cpython-*-darwin.so" 2>/dev/null | head -n 1)
if [ -z "$SO_FILE" ]; then
echo -e "${RED}Error: Could not find _phys.cpython-*-darwin.so in $SITE_PACKAGES/fourdst${NC}"
echo "Installation may have failed or the file is in an unexpected location."
exit 1
fi
echo "Found fourdst extension module: $SO_FILE"
echo ""
echo -e "${GREEN}Step 6: Running RPATH fix script for fourdst extension module...${NC}"
# Check if fix_rpath.py exists
FIX_SCRIPT="build-python/fix_rpaths.py"
if [ ! -f "$FIX_SCRIPT" ]; then
echo -e "${RED}Error: $FIX_SCRIPT not found${NC}"
echo "Please ensure you're running this script from the project root directory."
exit 1
fi
# Run the fix script
$PYTHON_BIN "$FIX_SCRIPT" "$SO_FILE"
if [ $? -ne 0 ]; then
echo -e "${RED}Error: RPATH fix script failed for fourdst extension module${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}=========================================================================${NC}"
echo -e "${GREEN} Installation Complete!${NC}"
echo -e "${GREEN}=========================================================================${NC}"
echo ""
echo "You can now use fourdst in your Python environment."
echo ""
echo "Test the installation with:"
echo " $PYTHON_BIN -c 'import gridfire; print(gridfire.__version__)'"
echo ""
echo -e "${YELLOW}Note:${NC} If you reinstall or upgrade fourdst, you will need to run this"
echo "script again to apply the RPATH fix."
echo ""