Skip to content

Commit e3bd6aa

Browse files
committed
v0.1.6
1 parent ec57217 commit e3bd6aa

File tree

3 files changed

+14
-51
lines changed

3 files changed

+14
-51
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ jobs:
281281
architecture: ${{ matrix.settings.architecture }}
282282
- name: Install dependencies
283283
run: pnpm install
284-
- name: Fix soname
285-
run: pnpm run build:fix
286-
shell: bash
287284
- uses: actions/download-artifact@v4
288285
with:
289286
name: bindings-${{ matrix.settings.target }}
@@ -379,6 +376,7 @@ jobs:
379376
380377
corepack disable
381378
npm i -gf pnpm
379+
node fix-python-soname.js
382380
pnpm install --prefer-offline
383381
pnpm test
384382

fix-python-soname.js

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,76 +21,43 @@ const arch = os.arch()
2121
// Function to detect if this is a development install vs dependency install
2222
function isDevInstall() {
2323
const env = process.env
24-
24+
2525
// Method 1: Check if INIT_CWD and PWD are the same (local dev install)
2626
if (env.INIT_CWD && env.PWD) {
2727
if (env.INIT_CWD === env.PWD || env.INIT_CWD.indexOf(env.PWD) === 0) {
2828
return true
2929
}
3030
}
31-
31+
3232
// Method 2: Check for .git folder existence (dev environment)
3333
if (fs.existsSync(path.join(__dirname, '.git'))) {
3434
return true
3535
}
36-
36+
3737
// Method 3: Check if we're in production mode
3838
if (env.NODE_ENV === 'production' || env.npm_config_production) {
3939
return false
4040
}
41-
41+
4242
return false
4343
}
4444

45-
// Function to find the correct .node file for this platform
46-
function findNodeFile() {
47-
// Only run on Linux - other platforms don't need soname fixing
48-
if (platform !== 'linux') return
49-
50-
// Map Node.js arch to napi-rs target
51-
const archMap = {
52-
'x64': 'x86_64-unknown-linux-gnu',
53-
'arm64': 'aarch64-unknown-linux-gnu',
54-
}
55-
56-
const target = archMap[arch]
57-
if (!target) return
58-
59-
// Try to find the .node file with various naming patterns
60-
const possiblePaths = [
61-
// Specific platform builds
62-
path.join(__dirname, `python-node.${target}.node`),
63-
path.join(__dirname, `index.${target}.node`),
64-
path.join(__dirname, `npm/${target}/python-node.${target}.node`),
65-
// Generic .node files (common during testing)
66-
path.join(__dirname, 'python-node.node'),
67-
path.join(__dirname, 'index.node'),
68-
// Look for any .node file in current directory
69-
...fs.readdirSync(__dirname)
70-
.filter(f => f.endsWith('.node') && !f.includes('node_modules'))
71-
.map(f => path.join(__dirname, f))
72-
]
73-
74-
for (const nodePath of possiblePaths) {
75-
if (fs.existsSync(nodePath)) {
76-
return nodePath
77-
}
78-
}
79-
80-
// Return undefined if no .node file found - this is expected during development
81-
return undefined
45+
// Only patch soname on Linux
46+
if (platform !== 'linux') {
47+
console.log(`No need to fix soname on platform: ${platform}`)
48+
process.exit(0)
8249
}
8350

8451
// Get the node file path
85-
const nodeFilePath = findNodeFile()
86-
if (!nodeFilePath) {
52+
const nodeFilePath = path.join(__dirname, `python-node.linux-${arch}-gnu.node`)
53+
if (!fs.existsSync(nodeFilePath)) {
8754
if (isDevInstall()) {
8855
// No .node file found during dev install - this is expected, skip silently
89-
console.log('No .node file found during development install, skipping soname fix')
56+
console.log(`${nodeFilePath} not found during development install, skipping soname fix`)
9057
process.exit(0)
9158
} else {
9259
// No .node file found when installed as dependency - this is an error
93-
console.error('Error: Could not find *.node file to fix soname')
60+
console.error(`Error: Could not find "${nodeFilePath}" to fix soname`)
9461
process.exit(1)
9562
}
9663
}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@platformatic/python-node",
33
"description": "Run ASGI-compatible Python apps in Node.js",
4-
"version": "0.1.5",
4+
"version": "0.1.6",
55
"main": "index.js",
66
"types": "index.d.ts",
77
"napi": {
@@ -30,10 +30,8 @@
3030
"artifacts": "napi artifacts",
3131
"build": "npm run build:debug -- --release",
3232
"build:debug": "napi build --platform --features napi-support",
33-
"build:fix": "node fix-python-soname.js",
3433
"build:wasm": "rustup target add wasm32-wasip1 && cargo build --package fix-python-soname --target wasm32-wasip1 --release && cp target/wasm32-wasip1/release/fix-python-soname.wasm .",
3534
"prepublishOnly": "npm run build:wasm && napi prepublish -t npm",
36-
"postinstall": "npm run build:fix",
3735
"lint": "oxlint",
3836
"test": "node --test test/**.test.mjs",
3937
"universal": "napi universal",

0 commit comments

Comments
 (0)