Skip to content

Commit 084ae12

Browse files
committed
Copy and munge the newer, and working, native sub from I::P5.
1 parent 9838e88 commit 084ae12

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/Inline/Python.pm6

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,33 @@ has &!call_method;
88
use NativeCall;
99

1010
sub native(Sub $sub) {
11-
my $so = 'pyhelper.so';
11+
my $so = $*VM.config<dll>;
12+
$so ~~ s!^.*\%s!pyhelper!;
13+
my $base = "lib/Inline/$so";
1214
state Str $path;
1315
unless $path {
1416
for @*INC {
15-
if "$_/Inline/$so".IO ~~ :f {
16-
$path = "$_/Inline/$so";
17+
my $cur = $_ ~~ Str ?? CompUnitRepo.new($_) !! $_;
18+
if my @files = ($cur.files($base) || $cur.files("blib/$base")) {
19+
my $files = @files[0]<files>;
20+
my $tmp = $files{$base} || $files{"blib/$base"};
21+
22+
# copy to a temp dir
23+
#
24+
# This is required because CompUnitRepo::Local::Installation stores the file
25+
# with a different filename (a number with no extension) that NativeCall doesn't
26+
# know how to load. We do this copy to fix the filename.
27+
$path = $*SPEC.tmpdir ~ '/' ~ $*PID ~ '-' ~ $so;
28+
29+
$tmp.IO.copy($path);
30+
}
31+
}
32+
}
33+
unless $path { # TEMPORARY !!!!
34+
for @*INC.grep(Str) {
35+
my $file = "$_.substr(5)/Inline/$so";
36+
if $file.IO.e {
37+
$path = $file;
1738
last;
1839
}
1940
}

0 commit comments

Comments
 (0)