@@ -21,76 +21,43 @@ const arch = os.arch()
2121// Function to detect if this is a development install vs dependency install
2222function 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}
0 commit comments