-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
115 lines (98 loc) · 3.25 KB
/
Copy pathbuild.sh
File metadata and controls
115 lines (98 loc) · 3.25 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
#!/bin/bash
# Copyright (c) 2025 Janea Systems
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
set -e
set -o pipefail
echo "Building and installing JECQ from source on $(uname -a)..."
pushd .
# Determine build configuration
buildType=Release
useLTO=ON
if [ "$1" == "Debug" ]; then
useLTO=OFF
buildType=Debug
fi
echo "Inferred build type: $buildType"
# Clean up any previous builds
rm -rf ./build_linux
mkdir ./build_linux
cd build_linux
pushd .
# Setup virtual environment
echo "Setting up virtual environment..."
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r ../jecq/python/requirements.txt
popd
# Set up Intel oneAPI environment
if [[ "$SETVARS_COMPLETED" != "1" ]]
then
echo "Running oneapi/setvars.sh..."
. /opt/intel/oneapi/setvars.sh
else
echo "Not running oneapi/setvars.sh; already run"
fi
# Build
echo "Running CMake and make step..."
cmake ../ -DCMAKE_BUILD_TYPE=$buildType \
-DFAISS_USE_LTO=$useLTO -DFAISS_OPT_LEVEL=avx2 \
-DBLA_VENDOR=Intel10_64lp -DMKL_LINK=static \
"-DMKL_LIBRARIES=-Wl,--start-group;libiomp5.a;${MKLROOT}/lib/intel64/libmkl_intel_lp64.a;${MKLROOT}/lib/intel64/libmkl_gnu_thread.a;${MKLROOT}/lib/intel64/libmkl_core.a;-Wl,--end-group" \
-DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DJECQ_ENABLE_PYTHON=ON
make -j 8
# Run tests
echo "Running tests..."
if [ -d ./tests ]; then
echo "Running C++ tests..."
if [ -f ./tests/jecq_test ]; then
echo "Running JECQ tests..."
./tests/jecq_test
else
echo "No JECQ tests found, skipping."
fi
else
echo "No tests directory found, skipping C++ tests."
fi
# Install Python package
echo "Installing Python package..."
pushd .
cd ./jecq/python
pip install wheel
python3 setup.py bdist_wheel
# Repair wheel for Linux compatibility
pip install auditwheel
pushd ./dist
for f in jecq*.whl; do
auditwheel repair "$f" -w . && rm "$f"
done
popd
# Install wheels
pip install dist/jecq*.whl
popd
# Verify installation
python3 -c "import jecq;jecq.IndexJecq();jecq.IndexIVFJecq()"
python3 -c "import jecq;assert jecq.IndexJecq.__module__ == 'jecq.swigjecq_avx2'"
# Update wheels
echo "Updating wheels..."
shopt -s globstar
# Create wheels directory if it doesn't exist
mkdir -p ../wheels/linux
cp ./**/jecq*.whl ../wheels/linux/
popd