-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup_python.sh
More file actions
executable file
Β·50 lines (41 loc) Β· 1.44 KB
/
setup_python.sh
File metadata and controls
executable file
Β·50 lines (41 loc) Β· 1.44 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
# creating setup_python.sh for CLi
echo "π Setting up Python bindings..."
# Build the Python extension
echo "Building Python extension..."
cargo build --features python --release
# Find the generated .so file
RUST_SO=$(find target/release -name "*.so" -type f | head -1)
if [ -z "$RUST_SO" ]; then
echo "β No .so file found. Trying debug build..."
cargo build --features python
RUST_SO=$(find target/debug -name "*.so" -type f | head -1)
fi
if [ -z "$RUST_SO" ]; then
echo "β Still no .so file found. Let's check what was built:"
echo "Files in target/debug:"
ls -la target/debug/
echo "Files in target/release:"
ls -la target/release/ 2>/dev/null || echo "No release directory"
exit 1
fi
echo "β
Found Rust library: $RUST_SO"
# Create a Python-importable module
# The .so file needs to be named correctly for Python to import it
if [[ "$RUST_SO" == *"libbip353"* ]]; then
# Copy and rename for Python import
PYTHON_SO="bip353.so"
cp "$RUST_SO" "$PYTHON_SO"
echo "β
Created Python module: $PYTHON_SO"
# Test the import
echo "Testing Python import..."
python3 -c "import bip353; print('β
Import successful!')" 2>/dev/null || {
echo "β Import failed. Let's check the file:"
ls -la bip353.so
file bip353.so
echo "Python path:"
python3 -c "import sys; print(sys.path)"
}
else
echo "β Unexpected .so filename: $RUST_SO"
exit 1
fi