Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,41 @@ concurrency:
cancel-in-progress: true

jobs:
build-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
fix-python-soname
sparse-checkout-cone-mode: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: wasm-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- name: Build WASM
working-directory: fix-python-soname
run: |
cargo build --target wasm32-wasip1 --release
cp target/wasm32-wasip1/release/fix-python-soname.wasm ../fix-python-soname.wasm
- name: Upload WASM artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-bindings
path: fix-python-soname.wasm

build:
needs: build-wasm
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -57,6 +91,11 @@ jobs:
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Download WASM artifacts
uses: actions/download-artifact@v4
with:
name: wasm-bindings
path: .
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: |
Expand Down Expand Up @@ -149,7 +188,6 @@ jobs:
git config --global url."ssh://git@github.com-http-handler/platformatic/http-handler.git".insteadOf "ssh://git@github.com/platformatic/http-handler.git"
git config --global url."ssh://git@github.com-http-rewriter/platformatic/http-rewriter.git".insteadOf "ssh://git@github.com/platformatic/http-rewriter.git"

npm run build:wasm
${{ matrix.settings.build }}
- name: Build
run: ${{ matrix.settings.build }}
Expand Down Expand Up @@ -431,7 +469,7 @@ jobs:
exit 1
fi
shell: bash
- name: Copy fix-python-soname files to Linux packages
- name: Copy fix-python-soname files to Linux and macOS packages
run: |
# Find the WASM and JS files from Linux artifacts
WASM_FILE=$(find artifacts -name "fix-python-soname.wasm" | head -n 1)
Expand All @@ -441,9 +479,9 @@ jobs:
echo "Found WASM file: $WASM_FILE"
echo "Found JS file: $JS_FILE"

# Copy to all Linux npm directories
# Copy to all Linux and macOS npm directories
for dir in npm/*/; do
if [[ "$dir" == *"linux"* ]]; then
if [[ "$dir" == *"linux"* ]] || [[ "$dir" == *"darwin"* ]]; then
echo "Copying files to $dir"
cp "$WASM_FILE" "$dir"
cp "$JS_FILE" "$dir"
Expand Down
18 changes: 10 additions & 8 deletions fix-python-soname.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@ function isDevInstall() {
return false
}

// Only patch soname on Linux
if (platform !== 'linux') {
// Only patch on Linux and macOS
if (platform !== 'linux' && platform !== 'darwin') {
console.log(`No need to fix soname on platform: ${platform}`)
process.exit(0)
}

// Get the node file path
const nodeFilePath = path.join(__dirname, `python-node.linux-${arch}-gnu.node`)
// Get the node file path based on platform
const nodeFilePath = platform === 'linux'
? path.join(__dirname, `python-node.linux-${arch}-gnu.node`)
: path.join(__dirname, `python-node.darwin-${arch}.node`)
if (!fs.existsSync(nodeFilePath)) {
if (isDevInstall()) {
// No .node file found during dev install - this is expected, skip silently
console.log(`${nodeFilePath} not found during development install, skipping soname fix`)
console.log(`${nodeFilePath} not found during development install, skipping binary patching`)
process.exit(0)
} else {
// No .node file found when installed as dependency - this is an error
console.error(`Error: Could not find "${nodeFilePath}" to fix soname`)
console.error(`Error: Could not find "${nodeFilePath}" to patch binary`)
process.exit(1)
}
}
Expand All @@ -67,7 +69,7 @@ const wasmPath = path.join(__dirname, 'fix-python-soname.wasm')
if (!fs.existsSync(wasmPath)) {
if (isDevInstall()) {
// WASM file not found during dev install - this is expected, skip with warning
console.log('WASM file not found during development install, skipping soname fix')
console.log('WASM file not found during development install, skipping binary patching')
process.exit(0)
} else {
// WASM file not found when installed as dependency - this is an error
Expand All @@ -76,7 +78,7 @@ if (!fs.existsSync(wasmPath)) {
}
}

console.log(`Running soname fix on ${nodeFilePath}`)
console.log(`Running binary patch on ${nodeFilePath}`)

// Create a WASI instance
const wasi = new WASI({
Expand Down
Loading
Loading