-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_python_lib.sh
More file actions
executable file
·66 lines (54 loc) · 1.78 KB
/
Copy pathbuild_python_lib.sh
File metadata and controls
executable file
·66 lines (54 loc) · 1.78 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
#!/bin/bash
# build_python_lib.sh - Build shared library for Python interface
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Building VERSE Python interface..."
echo ""
# Check if verse.c exists
if [ ! -f c/verse.c ]; then
echo "Error: verse.c not found in c/ subdirectory"
exit 1
fi
# Detect OS and build
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Detected macOS, building libverse.dylib..."
cc -O3 -fPIC -dynamiclib -o python/libverse.dylib c/verse.c -lm
if [ $? -eq 0 ] && [ -f python/libverse.dylib ]; then
echo "Successfully built python/libverse.dylib"
ls -lh python/libverse.dylib
else
echo "Failed to build libverse.dylib"
exit 1
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Detected Linux, building libverse.so..."
cc -O3 -fPIC -shared -o python/libverse.so c/verse.c -lm
if [ $? -eq 0 ] && [ -f python/libverse.so ]; then
echo "Successfully built python/libverse.so"
ls -lh python/libverse.so
else
echo "Failed to build libverse.so"
exit 1
fi
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
echo "Detected Windows, building verse.dll..."
cc -O3 -shared -o python/verse.dll c/verse.c -lm
if [ $? -eq 0 ] && [ -f python/verse.dll ]; then
echo "Successfully built python/verse.dll"
ls -lh python/verse.dll
else
echo "Failed to build verse.dll"
exit 1
fi
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi
echo ""
echo "=========================================="
echo "VERSE python library built successfully!"
echo ""
echo "To install the Python package, run:"
echo " pip install -e ."
echo "=========================================="