Subject: | Inline::Python should override sub Inline::check_installed |
Providing that Inline.pm is patched according to Inline bug 35517,
Installing a prebuilt Inline::Python module works well, if you
override Inline:check_installed.
Default Inline::check_installed looks for compiled *.so files.
By overriding this, Inline::Python should look for pre-built *.pydat files.
A work around is to have the Module using Inline::Python override the
check_installed in its own space.
Below is a working example.
package Inline;
#==============================================================================
# Check if Inline extension is preinstalled
#==============================================================================
sub check_installed {
my $o = shift;
$o->{INLINE}{object_ready} = 0;
unless ( $o->{API}{code} =~ /^[A-Fa-f0-9]{32}$/ ) {
require Digest::MD5;
$o->{INLINE}{md5} = Digest::MD5::md5_hex( $o->{API}{code} );
}
else {
$o->{INLINE}{md5} = $o->{API}{code};
}
return if $o->{CONFIG}{_INSTALL_};
return unless $o->{CONFIG}{VERSION};
croak M26_error_version_without_name()
unless $o->{CONFIG}{NAME};
my @pkgparts = split( /::/, $o->{API}{pkg} );
my $realname = File::Spec->catfile(@pkgparts) . '.pm';
my $realname_unix = File::Spec::Unix->catfile(@pkgparts) . '.pm';
my $realpath = $INC{$realname_unix}
or croak M27_module_not_indexed($realname_unix);
my ( $volume, $dir, $file ) = File::Spec->splitpath($realpath);
my @dirparts = File::Spec->splitdir($dir);
pop @dirparts unless $dirparts[-1];
push @dirparts, $file;
my @endparts = splice( @dirparts, 0 - @pkgparts );
$dirparts[-1] = 'arch'
if $dirparts[-2] eq 'blib' && $dirparts[-1] eq 'lib';
File::Spec->catfile(@endparts) eq $realname
or croak M28_error_grokking_path($realpath);
$realpath =
File::Spec->catpath( $volume, File::Spec->catdir(@dirparts), "" );
$o->{API}{version} = $o->{CONFIG}{VERSION};
$o->{API}{module} = $o->{CONFIG}{NAME};
my @modparts = split( /::/, $o->{API}{module} );
$o->{API}{modfname} = $modparts[-1];
$o->{API}{modpname} = File::Spec->catdir(@modparts);
my $suffix = 'pydat';
my $obj = File::Spec->catfile( $realpath, 'auto',
$o->{API}{modpname},
"$o->{API}{modfname}.$suffix" );
croak M30_error_no_obj( $o->{CONFIG}{NAME}, $o->{API}{pkg}, $realpath )
unless -f $obj;
@{ $o->{CONFIG} }{
qw( PRINT_INFO
REPORTBUG
FORCE_BUILD
_INSTALL_
)
}
= ( 0, 0, 0, 0 );
$o->{install_lib} = $realpath;
$o->{INLINE}{ILSM_type} = 'interpreted';
$o->{INLINE}{ILSM_module} = 'Inline::Python';
$o->{API}{location} = $obj;
$o->{INLINE}{ILSM_suffix} = $suffix;
$o->{INLINE}{object_ready} = 1;
}