File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 ],
3131 "link_settings" : {
3232 "libraries" : [
33- "<!(python3-config --ldflags --embed)"
33+ "<!(python3-config --ldflags --embed)" ,
34+ "<!(node ./scripts/rpaths.js)"
3435 ]
3536 },
36- 'cflags' : ['- fexceptions' ],
37- 'cflags_cc' : ['- fexceptions' ]
37+ 'cflags' : ["<!(python3-config --cflags)" , "- fexceptions" ],
38+ 'cflags_cc' : ["<!(python3-config --cflags)" , "- fexceptions" ]
3839 }],
3940 ['OS=="mac"' , {
4041 "include_dirs" : [
Original file line number Diff line number Diff line change @@ -8,17 +8,27 @@ class Interpreter
88 constructor ( )
99 {
1010 this . py = new nodecallspython . PyInterpreter ( ) ;
11- if ( process . platform === "linux" )
11+ if ( process . platform === "linux" || process . platform === "darwin" )
1212 {
1313 const stdout = execSync ( "python3-config --configdir" ) ;
1414 if ( stdout )
1515 {
1616 const dir = stdout . toString ( ) . trim ( ) ;
1717 if ( fs . existsSync ( dir ) )
1818 {
19+ const reg = process . platform === "linux" ? / l i b p y t h o n .* \. s o / : / l i b p y t h o n .* \. d y l i b / ;
1920 fs . readdirSync ( dir ) . forEach ( file => {
20- if ( file . match ( / l i b p y t h o n .* \. s o / ) )
21- this . fixlink ( path . join ( dir , file ) ) ;
21+ if ( file . match ( reg ) )
22+ {
23+ try
24+ {
25+ this . fixlink ( path . join ( dir , file ) ) ;
26+ }
27+ catch ( e )
28+ {
29+ console . error ( e ) ;
30+ }
31+ }
2232 } ) ;
2333 }
2434 }
Original file line number Diff line number Diff line change 1+ const { execSync } = require ( "child_process" ) ;
2+
3+ const stdout = execSync ( "python3-config --ldflags --embed" ) ;
4+ if ( stdout )
5+ {
6+ const splits = stdout . toString ( ) . trim ( ) . split ( " " ) ;
7+
8+ const result = [ ] ;
9+ splits . forEach ( s => {
10+ if ( s . startsWith ( "-L" ) )
11+ result . push ( s . substring ( 2 ) ) ;
12+ } ) ;
13+
14+ result . forEach ( ( r , i ) => {
15+ if ( i == 0 )
16+ {
17+ if ( result . length > 1 )
18+ console . log ( "-Wl,-rpath," + r + " \\" ) ;
19+ else
20+ console . log ( "-Wl,-rpath," + r ) ;
21+ }
22+ else if ( i + 1 == result . length )
23+ console . log ( "\t-Wl,-rpath," + r ) ;
24+ else
25+ console . log ( "\t-Wl,-rpath," + r + " \\" ) ;
26+ } ) ;
27+ }
Original file line number Diff line number Diff line change @@ -562,7 +562,15 @@ namespace nodecallspython
562562 if (valuetype == napi_string)
563563 {
564564 auto filename = convertString (env, args[0 ]);
565- dlopen (filename.c_str (), RTLD_LAZY | RTLD_GLOBAL );
565+ auto result = dlopen (filename.c_str (), RTLD_LAZY | RTLD_GLOBAL );
566+ if (!result)
567+ {
568+ auto error = dlerror ();
569+ if (error)
570+ napi_throw_error (env, " args" , error);
571+ else
572+ napi_throw_error (env, " args" , " Unknown error of dlopen" );
573+ }
566574
567575 return nullptr ;
568576 }
You can’t perform that action at this time.
0 commit comments