Skip to content

Commit afb72d0

Browse files
authored
Try removing patchelf dependency (#3)
1 parent a03e0e8 commit afb72d0

File tree

11 files changed

+829
-73
lines changed

11 files changed

+829
-73
lines changed

.github/workflows/CI.yml

Lines changed: 27 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ jobs:
142142
git config --global url."ssh://git@github.com-http-handler/platformatic/http-handler.git".insteadOf "ssh://git@github.com/platformatic/http-handler.git"
143143
git config --global url."ssh://git@github.com-http-rewriter/platformatic/http-rewriter.git".insteadOf "ssh://git@github.com/platformatic/http-rewriter.git"
144144
145+
npm run build:wasm
145146
${{ matrix.settings.build }}
146147
- name: Build
147148
run: ${{ matrix.settings.build }}
@@ -155,6 +156,8 @@ jobs:
155156
${{ env.APP_NAME }}.*.node
156157
index.d.ts
157158
index.js
159+
fix-python-soname.wasm
160+
fix-python-soname.js
158161
if-no-files-found: error
159162

160163
test-macOS-windows-binding:
@@ -239,6 +242,9 @@ jobs:
239242
cache: pnpm
240243
- name: Install dependencies
241244
run: pnpm install
245+
- name: Fix soname
246+
run: pnpm run build:fix
247+
shell: bash
242248
- uses: actions/download-artifact@v4
243249
with:
244250
name: bindings-${{ matrix.settings.target }}
@@ -332,79 +338,9 @@ jobs:
332338
apt-get update -y
333339
apt-get install -y python3 python3-dev patchelf
334340
335-
echo "=== Starting test setup ==="
336-
echo "Current directory: $(pwd)"
337-
echo "Python version: $(python3 --version)"
338-
echo "Patchelf version: $(patchelf --version)"
339-
echo "Using combined approach: SONAME patching + programmatic RTLD_GLOBAL"
340-
echo "CI environment: CI=$CI, GITHUB_ACTIONS=$GITHUB_ACTIONS"
341-
342-
# Check what .node files exist
343-
echo "=== Available .node files ==="
344-
ls -la *.node || echo "No .node files found"
345-
346-
# Check what .node files exist and patch Python dependencies
347-
echo "=== Checking .node file Python dependencies ==="
348-
for file in *.node; do
349-
if [ -f "$file" ]; then
350-
case "$file" in
351-
*linux*)
352-
echo "Checking $file..."
353-
echo "Python dependencies before patching:"
354-
ldd "$file" 2>/dev/null | grep python || echo "No Python dependencies found"
355-
356-
# Check if we need to patch SONAME
357-
current_python_lib=$(ldd "$file" 2>/dev/null | grep "libpython" | head -1 | awk '{print $1}')
358-
if [ -n "$current_python_lib" ]; then
359-
echo "Current Python library: $current_python_lib"
360-
361-
# Find the actual Python library on the system
362-
system_python_lib=$(find /usr/lib* -name "libpython3*.so.*" -type f 2>/dev/null | head -1)
363-
if [ -n "$system_python_lib" ]; then
364-
system_python_soname=$(basename "$system_python_lib")
365-
echo "System Python library: $system_python_soname"
366-
367-
# Only patch if they're different
368-
if [ "$current_python_lib" != "$system_python_soname" ]; then
369-
echo "Patching SONAME from $current_python_lib to $system_python_soname"
370-
patchelf --replace-needed "$current_python_lib" "$system_python_soname" "$file"
371-
echo "SONAME patching completed"
372-
else
373-
echo "SONAME already matches system Python"
374-
fi
375-
else
376-
echo "Warning: Could not find system Python library"
377-
fi
378-
else
379-
echo "No Python library dependency found"
380-
fi
381-
382-
echo "Python dependencies after patching:"
383-
ldd "$file" 2>/dev/null | grep python || echo "No Python dependencies found"
384-
echo "---"
385-
;;
386-
*)
387-
echo "Skipping non-Linux file: $file"
388-
;;
389-
esac
390-
fi
391-
done
392-
393-
# Install pnpm and run tests
394-
echo "=== Installing pnpm ==="
395341
corepack disable
396342
npm i -gf pnpm
397-
398-
echo "=== Running pnpm install ==="
399-
# Should be non-interactive in CI environment
400343
pnpm install --prefer-offline
401-
402-
echo "=== Setting up Python library path ==="
403-
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
404-
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
405-
406-
407-
echo "=== Running tests ==="
408344
pnpm test
409345
410346
publish:
@@ -430,6 +366,27 @@ jobs:
430366
path: artifacts
431367
- name: Move artifacts
432368
run: pnpm artifacts
369+
- name: Copy fix-python-soname files to Linux packages
370+
run: |
371+
# Find the WASM and JS files from Linux artifacts
372+
WASM_FILE=$(find artifacts -name "fix-python-soname.wasm" | head -n 1)
373+
JS_FILE=$(find artifacts -name "fix-python-soname.js" | head -n 1)
374+
375+
if [ -n "$WASM_FILE" ] && [ -n "$JS_FILE" ]; then
376+
echo "Found WASM file: $WASM_FILE"
377+
echo "Found JS file: $JS_FILE"
378+
379+
# Copy to all Linux npm directories
380+
for dir in npm/*/; do
381+
if [[ "$dir" == *"linux"* ]]; then
382+
echo "Copying files to $dir"
383+
cp "$WASM_FILE" "$dir"
384+
cp "$JS_FILE" "$dir"
385+
fi
386+
done
387+
else
388+
echo "Warning: fix-python-soname files not found in artifacts"
389+
fi
433390
- name: List packages
434391
run: ls -R ./npm
435392
shell: bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,6 @@ $RECYCLE.BIN/
199199
# Build/Install files
200200
/target
201201
/*.node
202+
/*.wasm
202203
/index.d.ts
203204
/index.js

0 commit comments

Comments
 (0)