-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
121 lines (104 loc) · 3.54 KB
/
install.sh
File metadata and controls
121 lines (104 loc) · 3.54 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
#!/bin/bash
set -euo pipefail
function usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -h, --help Show this help message"
echo " -b, --build-wheels Build the Python wheels"
echo " -a, --all Install with optional dependencies for development"
exit 1
}
# Parse command line arguments
BUILD_WHEELS=0
CMAKE_ARGS=""
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
;;
-b|--build-wheels)
BUILD_WHEELS=1
shift
;;
-a|--all)
CMAKE_ARGS="-DENABLE_LRB=ON -DENABLE_GLCACHE=ON -DENABLE_3L_CACHE=ON"
BUILD_WHEELS=0
shift
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
# For submodule update
git submodule update --init --recursive
git submodule update --recursive --remote
if [ $? -ne 0 ]; then
echo "Error: git submodule update failed"
exit 1
fi
# Detect Python command
PYTHON_CMD=""
if command -v python3 >/dev/null 2>&1; then
PYTHON_CMD="python3"
elif command -v python >/dev/null 2>&1; then
PYTHON_CMD="python"
else
echo "Error: python is not installed. Please install Python 3 and try again."
exit 1
fi
echo "Using Python command: $PYTHON_CMD"
$PYTHON_CMD scripts/sync_version.py
CMAKE_ARGS=$CMAKE_ARGS $PYTHON_CMD -m pip install -e . -vvv
# Test that the import works
echo "Testing import..."
$PYTHON_CMD -c "import libcachesim"
# Run tests
$PYTHON_CMD -m pip install pytest
$PYTHON_CMD -m pytest tests
if [[ "$CMAKE_ARGS" == *"-DENABLE_LRB=ON"* && "$CMAKE_ARGS" == *"-DENABLE_GLCACHE=ON"* && "$CMAKE_ARGS" == *"-DENABLE_3L_CACHE=ON"* ]]; then
echo "Running tests for optional eviction algos..."
$PYTHON_CMD -m pytest tests -m "optional"
fi
# Build wheels if requested
if [[ $BUILD_WHEELS -eq 1 ]]; then
echo "--- Building Python wheels for distribution ---"
# --- Environment and dependency checks ---
echo "Checking dependencies: python3, pip, docker, cibuildwheel..."
if ! command -v python3 >/dev/null 2>&1; then
echo "Error: python3 is not installed. Please install it and run this script again."
exit 1
fi
if ! python3 -m pip --version >/dev/null 2>&1; then
echo "Error: pip for python3 is not available. Please install it."
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Error: docker is not installed. Please install it and ensure the docker daemon is running."
exit 1
fi
# Check if user can run docker without sudo, otherwise use sudo
SUDO_CMD=""
if ! docker ps >/dev/null 2>&1; then
echo "Warning: Current user cannot run docker. Trying with sudo."
if sudo docker ps >/dev/null 2>&1; then
SUDO_CMD="sudo"
else
echo "Error: Failed to run docker, even with sudo. Please check your docker installation and permissions."
exit 1
fi
fi
if ! python3 -m cibuildwheel --version >/dev/null 2>&1; then
echo "cibuildwheel not found, installing..."
python3 -m pip install cibuildwheel
fi
echo "Dependency check completed."
# --- Run cibuildwheel ---
# The project to build is specified as an argument.
# cibuildwheel should be run from the repository root.
# The output directory will be 'wheelhouse/' by default.
echo "Starting the wheel build process for Linux..."
${SUDO_CMD} python3 -m cibuildwheel --platform linux .
echo "Build process completed successfully. Wheels are in the 'wheelhouse' directory."
fi